Compartilhar via


basic_ios::eof

Indicates if the end of a stream has been reached.

bool eof( ) const;

Return Value

true if the end of the stream has been reached, false otherwise.

Remarks

The member function returns true if rdstate & eofbit is nonzero. For more information on eofbit, see ios_base::iostate.

Example

// 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;
}

Sample Output

false
true

Requirements

Header: <ios>

Namespace: std

See Also

Reference

basic_ios Class

iostream Programming

iostreams Conventions

Other Resources

basic_ios Members