Possible Duplicate:
Why is iostream::eof inside a loop condition considered wrong?
I was reading a group of characters via cin.get() and I noticed that my cin.get() was getting an exra character at the end of the input. Might anyone know how to fix this? Here's my code:
unsigned char c;
while(!cin.eof())
{
c = cin.get();
cout << (int)c << endl;
}
My issue is that the character it gets is one of 255 ascii value. I simply don't want it to get this extra character, but if the user enters in a ascii value of 255 without it being a garbage character at the end, then that should be fine. An example would be so for my output:
if I entered in abc\n in my output:
I get 97 98 99 10 255
but I want: 97 98 99 10
Any ideas on how to fix this? Thanks!