/* 1-3 用标准I/O将标准输入复制到标准输出 */ /* 该题有助于理解输入输出缓冲区的概念 《APUE》P7*/ #include <stdio.h> #include <stdlib.h> #include <errno.h> int main(void) { char ch; while( (ch = fgetc(stdin)) != EOF ) { if( (fputc(ch, stdout)) == EOF ) { perror("output error"); exit(1); } } if(ferror(stdin)) { perror("intput error"); exit(1); } return 0; }