Is there any way to peek at the stdin buffer?
问题 We know that stdin is, by default, a buffered input; the proof of that is in usage of any of the mechanisms that \"leave data\" on stdin , such as scanf() : int main() { char c[10] = {\'\\0\'}; scanf(\"%9s\", c); printf(\"%s, and left is: %d\\n\", c, getchar()); return 0; } ./a.out hello hello, and left is 10 10 being newline of course... I\'ve always been curious, is there any way to \"peek\" at the stdin buffer without removing whatever may reside there? EDIT A better example might be: