5
当我到达myFile中的EOF时,Seekg似乎不起作用。为什么seekg不适用于getline?
ifstream myFile("/path/file");
for(int i; i < 10; i++){
myFile.seekg(0);//reset position in myFile
while(getline(myFile, line)){
doSomething
}
}
所以,现在我打开输入流的每一个循环:
for(int i; i < 10; i++){
ifstream myFile("/path/file");//reset position in myFile
while(getline(myFile, line)){
doSomething
}
}
但我宁愿寻求位置0。我怎样才能做到这一点?
可能重复的[seekg()函数失败](http://stackoverflow.com/questions/11264764/seekg-function-fails) – amo