Mega Code Archive

 
Categories / C++ Tutorial / Development
 

Using member functions get, put and eof

#include <iostream> using namespace std; int main() {    char c;    cout << "Before input, cin.eof() is " << cin.eof()         << "\nEnter a sentence followed by end-of-file:\n";    while ( ( c = cin.get() ) != EOF )       cout.put( c );    cout << "\nEOF in this system is: " << c;    cout << "\nAfter input, cin.eof() is " << cin.eof() << endl;    return 0; }