例子:
write()
就没有使用C语言的缓冲区#include <stdio.h>
#include <string.h>
int main()
{
const char *msg0="hello printf\n";
const char *msg1="hello fwrite\n";
const char *msg2="hello write\n";
printf("%s", msg0);
fwrite(msg1, strlen(msg0), 1, stdout);
write(1, msg2, strlen(msg2));
fork();
return 0;
}
hello printf
hello fwrite
hello write
./hello > file
, 我们发现结果如下hello write
hello printf
hello fwrite
hello printf
hello fwrite