I just wanted to know what's the difference between clear() and str("");
For example:
stringstream ss("Stack Overflow");
ss.clear();
ss.str("");
I wanted to know the underlying technical difference.
clear()
clears the error state flags in the stringstream
. That is to say it sets the error state to goodbit
(which is equal to zero).
str("")
sets the associated string object to the empty string.
They actually do completely different things. The peculiar choice of names only make it sound as though they perform similar tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With