home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG165.ARC / EW2ASCII.C < prev    next >
Text File  |  1979-12-31  |  1KB  |  42 lines

  1. /* Convert Early Word files to ASCII/WordStar files */
  2. /* Hi-tech v1.4 version    By Alan Laughton  8/6/91 */
  3.  
  4. #include     <STDIO.H>
  5.  
  6. main()  /* ew2ascii.c */
  7. {
  8.         FILE *fi, *fo;
  9.         int c, count;
  10.         char source[25], dest[25];
  11.  
  12.         puts("\n\nEarly Word files to ASCII files.\n");
  13.         printf("Input filename: ");
  14.         gets(source);
  15.         printf("Output filename: ");
  16.         gets(dest);
  17.  
  18.         if((fi = fopen(source,"rb")) == NULL) {
  19.                 printf("Can't open %s\n",source);
  20.                 exit();
  21.         }
  22.         if((fo = fopen(dest,"wb")) == NULL) {
  23.                 printf("Can't open %s\n",dest);
  24.                 exit();
  25.         }
  26.         printf("\nWorking...\n\n");
  27.  
  28.         count = 0;
  29.  
  30.         while ((c = getc(fi)) != EOF) {
  31.                 count++;
  32.                 if (count % 512 == 0)                 /*   put '*' */
  33.                                 printf("%c", '\052'); /* on screen */
  34.                 c = c & 127;                          /* every 512 */
  35.  
  36.                 if ( c == '\r')
  37.                                 putc('\n',fo);
  38.                 putc(c,fo);
  39.         }
  40.         printf("\n\nAll done.");
  41. }
  42.