/*  Kopieren von Files zur Standardausgabe;
         Argumente sind Filenamen oder - fuer Standardeingabe */

#include <stdio.h>
#define MAX 512

main(argc, argv)
char **argv;
{  
   void copy();
   register char **argp;
   register FILE *file;

   if (argc == 1) copy (stdin);
   else {
      argp=argv;
      while (--argc > 0)
         if ((*++argp)[0] == '-' && (*argp)[1]== '\0')
            copy(stdin);
         else if ((file = fopen(*argp, "r")) != NULL) {
            copy(file);
            fclose(file);
         } else
            fprintf(stderr, "%s: can't open %s\n", *argv, *argp);
   }  
}

void copy(file)
FILE *file;
{  
   char zf[MAX];

   while ((fgets(zf,MAX,file)) != NULL)
      fputs(zf,stdout);
}
