using namespace std;
int a ;
while ( ( a = cin.get() ) != EOF )
cout << "hi" <<endl;
} // end while
Your input actually consists of two characters: the character
1 followed by a newline.
Try piping in the contents of a file that only contains one byte, or a one-letter string without newline, and you'll see only one