Mega Code Archive

 
Categories / C++ Tutorial / File Stream
 

Display how many chars in ostrstream

#include <strstream> #include <iostream> using namespace std; int main() {   char str[80];   ostrstream outs(str, sizeof(str));   outs << "abcdefg ";   outs << 27 << " "  << 890.23;   outs << ends;  // null terminate   cout << outs.pcount(); // display how many chars in outs   cout << " " << str;   return 0; } 18 abcdefg 27 890.23"