Mega Code Archive

 
Categories / C++ Tutorial / File Stream
 

Ostrstream with format

#include <strstream> #include <iostream> using namespace std; int main() {   char str[80];   ostrstream outs(str, sizeof(str));   outs << "AAAAAAAAAAAAAAAA. ";   outs << 1024 << hex << " ";   outs.setf(ios::showbase);   outs << 100 << ' ' << 99.789 << ends;   cout << str;  // display string on console   return 0; } AAAAAAAAAAAAAAAA. 1024 0x64 99.789"