Watch out for short-circuit evaluation. Move (c = getchar()) != EOF to the front of the conditional.