mycat/mycat.c
1 #include "apue.h" 2 #define BUFFSIZE 4096 3 int 4 main(void) 5 { 6 int n; 7 char buf[BUFFSIZE]; 8 while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0) 9 if (write(STDOUT_FILENO, buf, n) != n) 10 err_sys("write error"); 11 if (n < 0) 12 err_sys("read error"); 13 exit(0); 14 }
将标准输入复制到标准输出
时间: 2024-10-05 03:26:35