For reading characters, you're on the right track, but it should be done like this:


int ch;
while( (ch = getchar()) != EOF && ch != '\n' )

Your way continues as long as getchar() returns a...