Probably truncation somewhere inside the loop.
The problem is that getchar()'s return value can either be EOF, or inside the domain of a char. If it's EOF and you assign to a char, you lose that information, and either the loop won't terminate or it might terminate on a regular char as well.
You should do it like this:
Code:
int t;
while((t = getchar()) != EOF) {
char c = (char)t;
// ...
}
Inside the loop, t must be in the domain of a char, so the cast is safe, and making it explicit prevents compiler warnings.