stringstream string to int

后端 未结 4 825
独厮守ぢ
独厮守ぢ 2021-02-05 12:17

The C++ code below does int to string and a string to int conversions. Then, it repeats these steps again. The stringst

4条回答
  •  不知归路
    2021-02-05 12:47

    The problem is that the stream's EOF flag is being set while extracting the integer (i.e. stream1.eof() returns true), but you never clear it. Inserting a call to stream1.clear() after extraction fixes your issue.

提交回复
热议问题