That doesn't make any sense to me, but hopefully one of you understands why he does it.
I have an assignment that requires three characters to be read with getchar (), since the three integers next to each other are related to each other, so I set up a loop structured as such:
int c1, c2, c3 = 0; while(c3 != EOF) { c1 = getchar(); c2 = getchar(); c3 = getchar(); ... do something with them... }
The problem is that if the number of characters is not divided by three, the last iteration is not performed. So, if the characters "Abcd" were entered, it would do the first iteration on Abc, but the second iteration would not do anything with D. The same thing for "Abcde", but Abcdef would work.
This is homework, so donβt solve the problem for me, but is it something weird about getchar that it just ends the loop if a lot of characters are not found?
source share