/* CRtoLF_c

   Author:  Timothy Swenson

   This program takes a file and translates
   all occurances of CR to LF.
*/

#include <stdio_h>

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

   int   i, fd1, fd2;

   printf("      CR to LF\n");
   printf("        By Tim Swenson\n\n");
   printf("Enter Input File Name : \n");
   gets(file);

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

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

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

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

   fclose(fd1);
   fclose(fd2);
}

