您的位置:首页 > 其它

1.2 将标准输入复制到标准输出

2014-07-13 23:06 225 查看
mycat/mycat.c

#include "apue.h"
#define    BUFFSIZE    4096
int
main(void)
{
int        n;
char    buf[BUFFSIZE];
while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0)
if (write(STDOUT_FILENO, buf, n) != n)
err_sys("write error");
if (n < 0)
err_sys("read error");
exit(0);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: