These threads do NOT answer me:
resetting a stringstream
How do you clear a stringstream variable?
std::ifstream file( szFIleName_p )
You didn't clear()
the stream after calling str("")
. Take another look at this answer, it also explains why you should reset using str(std::string())
. And in your case, you could also reset the contents using only str(szLine)
.
If you don't call clear()
, the flags of the stream (like eof
) wont be reset, resulting in surprising behaviour ;)