[lingyun@localhost io]$ vim io.c
{}
int n;
+ io.c
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: io.c
* Description: This file
*
* Version: 1.0.0(07/29/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "07/29/2013 04:46:06 PM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.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)
{
perror("write error");
exit(1);
}
if(n < 0)
{
perror("read error");
exit(0);
}
exit(0);
{}
int n;
+ io.c
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: io.c
* Description: This file
*
* Version: 1.0.0(07/29/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "07/29/2013 04:46:06 PM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.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)
{
perror("write error");
exit(1);
}
if(n < 0)
{
perror("read error");
exit(0);
}
exit(0);
}
[lingyun@localhost io]$ ./a.out
hello
hello
world
world