C++: Using ifstream with getline();

前端 未结 4 1790
名媛妹妹
名媛妹妹 2021-02-03 12:34

Check this program

ifstream filein(\"Hey.txt\");
filein.getline(line,99);
cout<

        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-03 12:37

    According to the C++ reference (here) getline sets the ios::fail when count-1 characters have been extracted. You would have to call filein.clear(); in between the getline() calls.

提交回复
热议问题