home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / ctutor2.zip / ANSWERS / CH10_1.C < prev    next >
Text File  |  1989-11-10  |  705b  |  39 lines

  1. #include "stdio.h"
  2.  
  3. main()
  4. {
  5. FILE *infile, *outfile, *printer;
  6. char c, infilename[25], outfilename[25];
  7.  
  8.    printf("Enter input file name ----> ");
  9.    scanf("%s",infilename);
  10.    infile = fopen(infilename,"r");
  11.  
  12.    printf("Enter output file name ---> ");
  13.    scanf("%s",outfilename);
  14.    outfile = fopen(outfilename,"w");
  15.  
  16.    printer = fopen("PRN","w");
  17.  
  18.    do {
  19.       c = getc(infile);
  20.       if (c != EOF) {
  21.          putchar(c);
  22.          putc(c,outfile);
  23.          putc(c,printer);
  24.       }
  25.    } while (c != EOF);
  26.  
  27.    fclose(printer);
  28.    fclose(infile);
  29.    fclose(outfile);
  30. }
  31.  
  32.  
  33.  
  34. /* Result of execution
  35.  
  36. (This program writes to the printer, a file, and the monitor.)
  37.  
  38. */
  39.