/*
* DESCRIPTION: read from stdin to stdout;
* copy any UNIX file context ;
* e.g: a.out > file.data;
* e.g: a.out < infile > outfile;
* DATE:8-23-2006
*/
#include "apue.h"
#define BUFSIZE 4096
int main(void)
{
int n;
char buf[BUFSIZE];
while((n = read(STDIN_FILENO, buf, BUFSIZE)) > 0)
if(write(STDOUT_FILENO, buf, n) != n)
err_sys("write error!");
if(n < 0)
err_sys("read error!");
return 0;
}