End of File in C++

前端 未结 3 785
再見小時候
再見小時候 2020-11-27 07:45

I have a n X 2 matrix stored in a text file as it is. I try to read it in C++

nb_try=0;
fin>>c_tmp>>gamma_tmp;
while (!fin.eof( ))      //if not          


        
3条回答
  •  伪装坚强ぢ
    2020-11-27 08:35

    IIRC, the eofbit doesn't get set until you actually try to read past the end of the file. That is, once you reach the end of the file, you have to read one more time before that flag will be set.

提交回复
热议问题