Reputation: 138
Why does this program print out blank?
string str;
stringstream ss(str);
ss << "A string";
cout << str; // just blank
Upvotes: 0
Views: 202
Reputation: 42888
stringstream
is not going to modify the argument you pass to its constructor.
Instead, you can get the current buffer from the stringstream
by calling its str
member function:
cout << ss.str();
Next time, consider reading the documentation.
Upvotes: 1