Easy way to create my output stream and keep with with a specific format in C++?

79 views Asked by At

There are several ways to do this (I believe). But I simply want a stream that will get all my data and output it to console. I tried using a stringstream by setting the strinstream::out flag and then doing a cout on the str() member function, but it didn't work as I expected.

Example:

somestream myS;
myS.flags(ios::left);
myS<<data<<data<<data<<endl;

This will either automatically output to console or I will have to do it manually (Somehow). The data will always be formatted to what I set.

P.s.: I can't use printf, or boost.

Thanks for your attention

1

There are 1 answers

1
roguequery On

sprintf is useful for printing out strings/null terminated strings in a useful fashion. Its old but it works. It can take variable arguments and the like. Sprintf(sprintf)