cat.c

[all poststhis post only]
#include <stdio.h>

int
main(int argc, char* argv[])
{
	char buf[4096];
	FILE* f;
	int i, n;

	for (i = 1; i < argc; ++i) {
		if (*argv[i] == '-' && *(argv[i]+1) == '\0')
			f = stdin;
		else {
			f = fopen(argv[i], "r");
			if (!f) {
				perror(argv[i]);
				return 1;
			}
		}
		while (n = fread(buf, 1, sizeof(buf), f))
			fwrite(buf, 1, n, stdout);
	}
}