//源代码
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
char buffer[4096];
int main(int argc,char **argv)
{
}
执行:
[root@localhost nbtest]# ./nbtest 5
delay = 5 seconds
stdin working in NONBLOCK, no data!: Resource temporarily unavailable
12345
Got 6 byte data.
12345
注意,
(1)在标准输入中键入回车后才算是有效输入。
(2)回车也算是输入的一个字符,比如输入12345+回车,实际读入的长度是6个字节。