Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: