home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_06 / 8n06076a < prev    next >
Text File  |  1990-05-01  |  967b  |  47 lines

  1.  
  2. Listing 8:
  3.  
  4.  
  5.    #include <stdio.h>
  6.  
  7.    #define MS_DOS_EOF 26
  8.    #define MS_DOS_CR 13
  9.  
  10.    main(argc, argv)
  11.    /* Translate MS-DOS text file to UNIX file */
  12.    /**** Does not check for errors *****/
  13.    /* Usage   translate  file-in  file-out */
  14.    int argc;
  15.    char *argv[];
  16.        {
  17.        int c;
  18.        FILE *file_in, file_out;
  19.  
  20.        file_in = fopen(argv[1],"rb");
  21.        file_out = fopen(argv[2],"wb");
  22.  
  23.        while (1)
  24.            {
  25.            c = fgetc(file_in);
  26.            switch(c)
  27.                {
  28.            case EOF:
  29.            case MS_DOS_EOF:        
  30.                /* All done */
  31.                goto end;
  32.                break;
  33.            case MS_DOS_CR:
  34.                /* Ignore the CR value */
  35.                break;
  36.            default:
  37.                fputc(c, file_out);
  38.                break;
  39.                }
  40.            }
  41. end:
  42.        fclose(file_in);
  43.        fclose(file_out);
  44.        exit(0);
  45.        }   
  46.  
  47.