Hello,
How do you clear the contents of an ostringstream object? I've included
some example code so you can see what I mean.
t.i.a.
Craig H.
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;
int main(int argc, char* argv[])
{
string a("hello");
string b("world");
string s1;
ostringstream oss;
oss << setiosflags(ios::left) << setfill('O') << setw(10) << a << endl;
s1 = oss.str();
cout << s1;
// how do you clear the ostringstream oss?
oss << resetiosflags(ios::left) << setfill('W') << setw(10) << b << endl;
s1 = oss.str();
cout << s1;
system("PAUSE");
return EXIT_SUCCESS;
}
/*
-curent output-
helloOOOOO
helloOOOOO
WWWWWworld
-desired output-
helloOOOOO
WWWWWworld
*/
--
"Communism won't work because people like to own stuff."