[英]How to go back to the beginning of a file after reaching .eof() in C++?
Did you try the accepted answer?您是否尝试过接受的答案? The call to clear
is the key. clear
呼叫是关键。
OK, it works.好的,它有效。 The trick is call诀窍是打电话
file.clear();
file.seekg(0, ios::beg);
just after the iteration.就在迭代之后。 Sorry:(对不起:(
If your input is a stream (data piped in from another program) then you will not be able to seek.如果您的输入是 stream(从另一个程序输入的数据),那么您将无法搜索。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.