char c = getchar(); while (c != EOF) { c = getchar(); … }
Which not only reads badly but requires writing the "producer" twice. Though alternatively you could:
while (1) { c = getchar(); if (c == EOF) { break; } ... }
char c; do { c = getchar(); } while (c != EOF);
int c; //a char can't represent EOF do { c = getchar(); if (c != EOF) { //do stuff } } while (c != EOF);
Which not only reads badly but requires writing the "producer" twice. Though alternatively you could: