cat, but there are no cats on the internet.
/* POSIX cat implementation */
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv){
int uflag = 0, retval = 0;
if(*argv && *++argv) {
if(! strcmp(*argv, "-u"))
{
uflag = 1;
setvbuf(stdout, NULL, _IONBF, 0);
argv++;
}
}
do
{
FILE* input;
int c;
if(! *argv || ! strcmp(*argv, "-")) {
input = stdin;
}
else
{
input = fopen(*argv, "rb");
if(! input)
{
fprintf(stderr, "Unable to open %s: ", *argv);
perror(NULL);
retval = 1;
continue;
}
}
if(uflag)
setvbuf(input, NULL, _IONBF, 0);
while((c = fgetc(input)) != EOF)
{
if(putchar(c) == EOF)
{
perror("Output failure");
return 1;
}
}
} while (*argv && *++argv);
return retval;
}