home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / convergent / cthex.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  631b  |  31 lines

  1. #include <stdio.h>
  2.  
  3. main(argc, argv)
  4. int argc;
  5. char *argv[];
  6. {
  7.     FILE *in_fp;
  8.     FILE *out_fp;
  9.     int a;
  10.     int char_count = 0; 
  11.  
  12.     if ((in_fp = fopen(argv[1],"r")) == NULL) {
  13.         printf("cannot open file %s\n", argv[1]);
  14.         exit(1);
  15.     }
  16.     if ((out_fp = fopen(argv[2],"w")) == NULL) {
  17.         printf("cannot open file %s\n", argv[2]);
  18.         exit(1);
  19.     }
  20.     while ((a = fgetc(in_fp)) != EOF) {
  21.         fprintf(out_fp, "%02X", a);
  22.         if (++char_count >= 40) {
  23.             fputc('\n', out_fp);
  24.             char_count = 0;
  25.         }
  26.     }
  27.     fputc('\n', out_fp);
  28.     fclose(in_fp);
  29.     fclose(out_fp);
  30. }
  31.