eof problem c++

前端 未结 3 880
庸人自扰
庸人自扰 2020-12-07 03:48

i am using Dev C++ on windows xp

#include 
#include 
#include 
using namespace std;

int main ()
{
    string S         


        
相关标签:
3条回答
  • 2020-12-07 04:08

    If you change your loop to

      while(getline(infile,STRING))
      {
         cout<<STRING; 
      }
    

    you avoid the possibility of reading the last value twice (see this SO post).

    0 讨论(0)
  • 2020-12-07 04:08

    std::ifstream::eof is a function that returns a bool. Thsu you have to call it like

    infile.eof()
    
    0 讨论(0)
  • 2020-12-07 04:24

    You forgot the () after the eof.

    0 讨论(0)
提交回复
热议问题