I/O -x std read write

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <error.h>
#include <errno.h>
#include <string.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)
		{printf("exception happened des is %s,number is %d\n",strerror(errno),errno);
		return 0;}
	}
}
int main (void)
{
	int c;
	while((c=getc(stdin)) !=EOF)
		if(putc(c,stdout) ==EOF)
		printf("error");
	exit(0);
}

  

posted @ 2015-05-16 12:57  pencil_zh  阅读(123)  评论(0编辑  收藏  举报