[comp.lang.c] Help! Can you figure out this program?

stanley@phoenix.com (John Stanley) (01/18/91)

From jph@ais.org (Joseph Hillenburg) <7$T+NM%@irie.ais.org>:

> This is a program originally written for VMS, which converts text into
> rot13, and used to work. However, I ported it to UNIX, and it still
> worked, but when I added the routine to figure out what name you ran it by,
> it died. I know this is real simple, but I can't figure it out. I'd
> appreciate mail, and a comment telling me *what* has been changed, so I don't
> have to ask next time. :)

   Included are the errors produced by my compiler. Not all of them,
just the first few. Check the ones for lines 33 and 36 and see if they
give you some hints. (I.e. WHY is line 36 an error?) Then find a
compiler that gives you error messages. 

-----------------------
#include <stdio.h>
#include <ctype.h>

int
main(argc, argv)
char *argv[];
char *progname;
Error rot13.c 33: 'progname' not an argument in function main
{
   progname = argc[0];
Error rot13.c 35: Undefined symbol 'progname' in function main
Error rot13.c 35: Invalid indirection in function main
   char ch;
Error rot13.c 36: Expression syntax in function main
   FILE *infile,*outfile, *out;
Error rot13.c 37: Improper use of a typedef symbol in function main
Error rot13.c 37: Undefined symbol 'infile' in function main
Error rot13.c 37: Undefined symbol 'outfile' in function main
Error rot13.c 37: Invalid indirection in function main
Error rot13.c 37: Undefined symbol 'out' in function main
Error rot13.c 37: Invalid indirection in function main
   /* kick out if there are more than 2 arguments or less than 1 */
   if ((argc < 2) || (argc >3))
   {
        int sec = 10, status, onalarm();
        if (argc > 1 && argv[1][0] == '-') {
           sec = atoi(&argv[1][1]);
           argc--;
           argv++;
         }
      puts("\nUsage: %s <infile> [outputfile]\n");
Human Detected Error: the %s in the above line will not expand in a puts().
      exit(1);