Hello.
On Linux, I can read available input without blocking the process:
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK )
char buf[n];
int r = fread(buf, 1, n, stdin);
if (r == 0){
printf("nothing\n");
}
else {
printf("read: ");
fwrite(buf, 1, r, stdout);
printf("\n");
}
The input origin can be anything, such as a file, a terminal or a pipe.
How can I do it on Windows XP?
Thanks.