/*
 ============================================================================
 Name        : test.c
 Author      : blank
 Version     :
 Copyright   : Your copyright notice
 Description : 程序3-3 将标准输入复制到标准输出
 ============================================================================
*/

#include <stdio.h>
#include <unistd.h>
#include "ourhdr.h"

#define BUFFSIZE 4096

int main(int argc, char *argv[])
{
	char buf[BUFFSIZE];
	int  n;

	while((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0){
		if ((n = write(STDOUT_FILENO, buf, n)) != n){
			err_sys("write to STDOUT_FILENO error\n");
		}
	}

	if (n < 0){
		err_sys("read from STDIN_FILENO error\n");
	}
	exit(0);
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
猜你喜欢
  • 2021-11-13
  • 2021-07-16
  • 2021-11-11
  • 2022-12-23
  • 2021-05-20
  • 2021-12-04
  • 2021-05-26
相关资源
相似解决方案