/* File:     CRtoLF_c
   Author:   Timothy Swenson

   Converts all CR's to LF's

   This program will take a file that came
   from the Z88 with CR's for End-Of-Line
   markers and convert them to LF's (QL
   End-OF-Line markers).

*/

/* #define  CR      13  defined in STDIO_H */
/* #define  LF      10  defined in STDIO_H */

#include <stdio_h>

main() {
   char  c, file[30];

   int   fd1, fd2;

   printf("Enter Input File Name : \n");
   gets(file);

   fd1 = fopen(file,"r");
   if (fd1 == NULL)  {
      printf("Did not open input file: %s",file);
      abort(1);
   }

   printf("Enter Output File Name : \n");
   gets(file);

   fd2 = fopen(file,"w");
   if (fd2 == NULL) {
      printf("Could not open output file: %s\n",file);
      abort(1);
   }

   while (( c = getc(fd1)) != EOF) {
          if ( c == CR )
             putc(LF,fd2);
          else
             putc(c,fd2);
   }

   fclose(fd1);
   fclose(fd2);
}

