(Learning C++) I have been looking at code portion below:
stringstream ss;
// more code
ss.clear();
ss.str("");
Why is ss.str("");
called when ss.clear();
is meant to remove the string value? I printed out the str()
value to std::cout
and saw that it had length zero without the line ss.str("");
so why is it included?
In my research, I ran into this question and the accepted answer by @Johannes Schaub - litb does the same thing. What am I missing out.