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