| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Public member functions | ||||
strstreambuf::pcount | ||||
| Protected member functions | ||||
int pcount()const; | (deprecated in C++98) (removed in C++26) | |
Returns the number of characters written to the output sequence.
If the next pointer for the put area (std::streambuf::pptr()) is a null pointer, returns zero.
Otherwise, returns the next pointer in the put area minus the beginning pointer in the put area, that ispptr()- pbase().
Contents |
(none)
The number of characters written to the put area.
#include <iostream>#include <strstream> int main(){std::strstream dyn;// dynamically-allocated output buffer dyn<<"Test: "<<1.23<<std::ends;std::strstreambuf* buf= dyn.rdbuf();std::cout<<"The size of the output is "<< buf->pcount()// or just buf.pcount()<<" and it holds\""<< dyn.str()<<"\"\n"; dyn.freeze(false);// after calling .str() on a dynamic strstream char arr[10];std::ostrstream user(arr,10);// user-provided output buffer buf= user.rdbuf(); user<<1.23;// note: no std::endsstd::cout.write(arr, buf->pcount());// or just user.pcount()std::cout<<'\n'; std::istrstream lit("1 2 3");// read-only fixed-size buffer buf= lit.rdbuf();// istrstream has no member pcount(), so lit.pcount() won't workstd::cout<<"Input-only pcount() = "<< buf->pcount()<<'\n';}
Output:
The size of the output is 11 and it holds "Test: 1.23"1.23Input-only pcount() = 0
| obtains the number of characters written (public member function of std::strstream)[edit] | |
| obtains the number of characters written (public member function of std::ostrstream)[edit] |