I figured out why the following loop was giving me bad input, re Why is “while ( !feof (file) )” always wrong?
do {
    if (fread(buf, 1, siz, stdin) != siz) {
        if (feof(stdin))
            fputs("bad input\n", stderr);
        else /* implying ferror(stdin) */
            perror("fread() failed");
        return EXIT_FAILURE;
    }
    use(buf);
} while (!feof(stdin));
Is it inevitable to write some auxiliary function/weird call for properly(?) checking EOF along the lines of ungetc(getchar(), stdin) or is there a better way?
 
     
    