让我们看看这个程序:
ifstream filein("hey.txt");
if(filein.eof()){
cout<<"END"<<endl;
}
Run Code Online (Sandbox Code Playgroud)
这里"hey.txt"是空的.所以这里的if条件被认为应该是真的但它不是
尽管文件为空,为什么eof不返回true?
如果我if在eof返回true 之前添加了这个,尽管arr仍然是空的并且文件仍为空,因此两者都保持不变
char arr[100];
filein.getline(arr,99);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3874 次 |
| 最近记录: |