Listing 8

   #include <stdio.h>

   #define MS_DOS_EOF 26
   #define MS_DOS_CR 13

   main(argc, argv)
   /* Translate MS-DOS text file to UNIX file */
   /**** Does not check for errors *****/
   /* Usage   translate file-in   file-out */
   int argc;
   char *argv[];
      {
      int c;
      FILE *file_in, file_out;

      file_in = fopen(argv[1],"rb");
      file_out = fopen(argv[2],"wb");

      while (1)
         {
         c = fgetc(file_in);
         switch(c)
            {
         case EOF:
         case MS_DOS_EOF:
            /* All done */
            goto end;
            break;
         case MS_DOS_CR:
            /* Ignore the CR value */
            break;
         default:
            fputc(c, file_out);
            break;
            }
         }
end:
      fclose(file_in);
      fclose(file_out);
      exit(0);
      }