c++ 文件结束判断

出处:http://blog.csdn.net/shuilan0066/article/details/4669451

 

1、

ifstream in("config.txt", ios::in);
if (!in)
{
  cerr << "open file failed!";  
  exit(-1);  
}

while(in.peek()!=EOF)
{
    //do something
}

 

  

 

posted @ 2018-06-05 16:40  -南  阅读(271)  评论(0编辑  收藏  举报