home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / elem-c.zip / BACKUP.C < prev    next >
Text File  |  1985-05-18  |  1KB  |  43 lines

  1. /*
  2. **    backup an ascii file
  3. *************************************************************  */
  4.  
  5.  
  6. #include "stdio.h"
  7.  
  8. main()
  9.     {
  10.         char in_name[11], out_name[15];
  11.         FILE *read_file, *out_file, *fopen ();
  12.         int c;
  13.  
  14.         printf("enter name of file to be backed up : ");
  15.         scanf ("%.10s", &in_name);
  16.         printf("%s\n",in_name);
  17.         printf("enter name of backup file : ");
  18.         scanf ("%.14s", &out_name);
  19.  
  20.         read_file = fopen (in_name, "r");
  21.  
  22.         if ( read_file == NULL )
  23.             printf("couldn't open %s for reading.\n",in_name);
  24.         else
  25.             {
  26.                 out_file = fopen (out_name, "w");
  27.                     if (out_file == NULL )
  28.                         Printf("couldn't open %s for writing.\n",out_name);
  29.                     else
  30.                     {
  31.                         while ( (c = getc(read_file)) != EOF )
  32.                             putc (c, out_file);
  33.  
  34.                         printf("file has been BACKED UP!\n");
  35.  
  36.                         }
  37.                 }
  38.                     fclose(out_file);
  39.                     fclose(read_file);
  40.  
  41.     }
  42.