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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
clear()clears the error state flags in thestringstream. That is to say it sets the error state togoodbit(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.