Possible Duplicate:
Why is iostream::eof inside a loop condition considered wrong?
I've got very simple question...
#include<iostream>
using namespace std;
int main()
{
char x;
while(!cin.eof())
{
cin>>x;
cout<<"char: "<< x << endl;
}
return 0;
}
Why when i try to run this code on Linux:
./file_name < test_file.txt
The result is:
char: a
char: b
char: c
char: d
char: d
when test_file.txt is only:
abcd