std::strstream::pcount
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Input/output library 
 
 
 
 
 
 
 
 
 
 
 
 
 Print functions (C++23)
 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)
std::strstream 
 
 Member functions
strstream::pcount
int pcount() const;
 
 (deprecated in C++98) (removed in C++26)
Returns the number of characters that were output in the put area of the associated std::strstreambuf . Effectively calls rdbuf()->pcount().
Contents
[edit] Parameters
(none)
[edit] Return value
The number of characters in the put area, or zero if nothing was output.
[edit] Example
Run this code
#include <iostream> #include <strstream> int main() { std::strstream dyn; // dynamically-allocated output buffer dyn << "Test: " << 1.23 << std::ends ; std::cout << "The size of the output is " << dyn.pcount() << " and it holds \"" << dyn.str() << "\"\n"; dyn.freeze(false); char buf[10]; std::strstream user(buf, 10); // user-provided output buffer user << 1.23; // note: no std::ends std::cout.write(buf, user.pcount()); std::cout << '\n'; }
Output:
The size of the output is 11 and it holds "Test: 1.23" 1.23