basic_ios::eof
指示流的结尾是否已到达。
bool eof( ) const;
返回值
true,如果流的末尾已到达,否则 false。
备注
如果 rdstate& eofbit 不为零,成员函数返回 true。 有关 eofbit 的更多信息,请参见 ios_base::iostate。
示例
// basic_ios_eof.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>
using namespace std;
int main( int argc, char* argv[] )
{
fstream fs;
int n = 1;
fs.open( "basic_ios_eof.txt" ); // an empty file
cout << boolalpha
cout << fs.eof() << endl;
fs >> n; // Read the char in the file
cout << fs.eof() << endl;
}
示例输出
false
true
要求
标头: <ios>
命名空间: std