#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

extern int errno;

#ifndef EOF
#define EOF -1
#endif

void dumpfile (FILE *thefile) {
   int ch;

   while ((ch = getc (thefile)) != EOF)
      putchar (ch);

/* Alternate, more Pascal-ish version of this loop:	*/
/* ch = getc (thefile);					*/
/* while (! feof (thefile)) {				*/
/*    putchar (ch);					*/
/*    ch = getc (thefile);				*/
/*    }							*/
   }


void main (int argc, char **argv) {
   char *filename;

   switch (argc) {
      case 0: printf ("This can't happen.\n");
              break;
      case 1: /* No arguments; use stdin. */
              dumpfile (stdin);
	      break;
      default: {
              FILE *thefile;
              int i;
              for (i=1; i<argc; i++) {
                  thefile = fopen (argv[i], "r");
                  if (thefile) {
                     dumpfile (thefile);
                     }
                  else {
                     fprintf (stderr, "Problem opening file %s: %d.\n",
                              argv[i], errno);
                     perror (argv[0]);
                     }
                  }
              break;
	      }
      }
   }

