How does ifstream's eof() work?

#include <iostream> #include <fstream> int main() { std::fstream inf( "ex.txt", std::ios::in ); while( !inf.eof() ) { std::cout << inf.get() << "\n"; } ...