共用方式為


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

請參閱

參考

basic_ios 類別

iostream 程式設計

iostreams 慣例