Skip to content

Instantly share code, notes, and snippets.

@uhziel
Created September 25, 2011 16:27
Show Gist options
  • Save uhziel/1240801 to your computer and use it in GitHub Desktop.
Save uhziel/1240801 to your computer and use it in GitHub Desktop.
apue.2e.fig1.4.c
#include "apue.h"
#define BUFFSIZE 4096
int main()
{
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");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment