C++ - repeatedly using istringstream

烂漫一生 提交于 2019-11-27 04:48:43

After setting the row into the istringstream...

separate.str(row);

... reset it by calling

separate.clear();

This clears any iostate flags that are set in the previous iteration or by setting the string. http://www.cplusplus.com/reference/iostream/ios/clear/

You need to add a separate.clear(); line after separate.str(row) to clear the status bits, otherwise the eofbit gets set and subsequent reads fail.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!