/* Convert.c */
#include <stdio.h>  /* necessary for file I/O */

int main()
{
 int ch;            /* Declare character variable used for input. */
 char inputfile[80], outputfile[80];
 FILE *infile;    /* Declare file pointer for input file. */
 FILE *outfile;   /* Declare file pointer for output file. */

 /* get the filenames from the user */
 printf("What file do you want to convert to uppercase? ");
 scanf("%s", inputfile);
 printf("What file name do you want for the copy? ");          
 scanf("%s", outputfile);

 /* open the files */
 infile = fopen(inputfile, "r");
 outfile = fopen(outputfile, "w");

 if ((!infile) || (!outfile))  /* If file error on either file, */
  {                            /* print message and stop program. */
    printf("Error opening file.\n");
    return 0;
  }
   /* copy the file char by char */
 while( (ch = fgetc(infile)) != EOF)
 {
   if((ch >= 0x61) && (ch <= 0x7a))
     ch -= 32;
   fputc(ch, outfile);
 }

 fclose(infile);
 fclose(outfile);
 return 0;
}

