basic_ios::eof

表示資料流的結尾是否已到達。

bool eof( ) const;

傳回值

true ,如果已經到達資料流結尾時,則為 false 。

備註

如果 rdstate& eofbit 為非零值 (Nonzero),則成員函式傳回 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

請參閱

參考

basic_ios Class

iostream 程式設計

iostreams 慣例