home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_01 / 1n01038a < prev    next >
Text File  |  1990-05-17  |  958b  |  48 lines

  1. /*
  2. **  Figure 1
  3. **
  4. **  change_prn()
  5. **
  6. **  A function to change the standard printer device for the duration
  7. **  of a program. Valid new device codes are:
  8. **
  9. **      0 - LPT1
  10. **      1 - LPT2
  11. **      2 - LPT3
  12. **      3 - COM1
  13. **      4 - COM2
  14. **      5 - CON
  15. */
  16.  
  17. #include <stdio.h>
  18.  
  19. int change_prn(int device)
  20. {
  21.         char *newdev;
  22.  
  23.         switch (device)
  24.         {
  25.         case 0:
  26.                 newdev = "LPT1";
  27.                 break;
  28.         case 1:
  29.                 newdev = "LPT2";
  30.                 break;
  31.         case 2:
  32.                 newdev = "LPT3";
  33.                 break;
  34.         case 3:
  35.                 newdev = "COM1";
  36.                 break;
  37.         case 4:
  38.                 newdev = "COM2";
  39.                 break;
  40.         case 5:
  41.                 newdev = "CON";
  42.                 break;
  43.         default:
  44.                 return -1;
  45.         }
  46.         return (NULL == freopen(newdev, "w", stdprn));
  47. }
  48.