Mega Code Archive

 
Categories / C++ Tutorial / File Stream
 

Output string and decimal in hexadecimal format to a file with ostrstream

#include <strstream>     #include <iostream>    using namespace std; main()    {      char str[80];      int a = 10;            ostrstream outs(str, sizeof(str));            outs << "Hello there ";      outs << a+44 << hex << " ";      outs.setf(ios::showbase);      outs << 100 << ends;            cout << str;         return 0;    }