#include #include static void usage (void) __attribute__ ((unused)); int main (int argc, char *argv[]) { if (argc < 2) { int c; while ((c = getchar()) != EOF) { putchar(c); } return EXIT_SUCCESS; } FILE *fp = fopen(argv[1], "r"); if (fp == NULL) { return EXIT_FAILURE; } int c; while ((c = fgetc(fp)) != EOF) { putchar(c); } fclose(fp); return EXIT_SUCCESS; } static void usage (void) { printf ("cat, print the contents of a file\n"); printf ("usage: cat FILE\n"); }