Partager via


basic_ios::eof

Indicates if the end of a stream has been reached.

bool eof( ) const;

Return Value

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

Remarks

boolalpha specifies the format of a bool variable.

The member function returns true if rdstate & eofbit is nonzero.

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 << fs.eof() << endl;
   fs >> n;   // Read the char in the file
   cout << fs.eof() << endl;
}

Sample Output

0
1

Requirements

Header: <ios>

Namespace: std

See Also

Concepts

basic_ios Class

basic_ios Members

iostream Programming

iostreams Conventions