C- nonblocking read of all stdin

476 views Asked by At

I am seeking some non-blocking function (will return any available input but will not wait for more input from the user) which will read any and all stdin data up to n into a buffer and return how many bytes were read.

int n_bytes = readn(&buff, length);
if (n_bytes > 0) {
...

My current attempt uses getchar() until EOF, but that waits for input. I would like to avoid multithreading if possible.

0

There are 0 answers