4 ms·
The correct way is int ch; while ((ch = getchar()) != EOF) { // ... } If ch is declared as a char, it's buggy regardless of whether it's
by mooism2 18y ago
The correct way is
int ch;
while ((ch = getchar()) != EOF) {
// ...
}
If ch is declared as a char, it's buggy regardless of whether it's signed or not, it's just the failure modes are different.