1.3 用标准I/O将标准输入复制到标准输出
mycat/getcputc.c
1 #include "apue.h" 2 int 3 main(void) 4 { 5 int c; 6 while ((c = getc(stdin)) != EOF) 7 if (putc(c, stdout) == EOF) 8 err_sys("output error"); 9 if (ferror(stdin)) 10 err_sys("input error"); 11 exit(0); 12 }
mycat/getcputc.c
1 #include "apue.h" 2 int 3 main(void) 4 { 5 int c; 6 while ((c = getc(stdin)) != EOF) 7 if (putc(c, stdout) == EOF) 8 err_sys("output error"); 9 if (ferror(stdin)) 10 err_sys("input error"); 11 exit(0); 12 }