home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 336_01 / out.c < prev    next >
Text File  |  1990-10-26  |  2KB  |  90 lines

  1. /*
  2. *            O U T P U T F O R M . C
  3. *
  4. *                       written by Marwan El-Augi 22-oct-1990
  5. *
  6. *           utility for printing number columns for edipal
  7. *
  8. *           copyright (c) 1990, Marwan EL-AUGI, MEASoftlines, France
  9. *           but distribution is not restricted as long as done
  10. *           in a freeware form
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <process.h>
  15.  
  16.  
  17. #define  MAX    31
  18. #define  OK     0
  19. #define  BAD    1
  20.  
  21. void xprt(FILE *name);
  22. void bye(int status);
  23. void _Cdecl clrscr(void);  /*  from conio.h  include file */
  24.  
  25. char *title = "Palette codes chart";
  26.  
  27. int status;
  28.  
  29. void main(int argc, char *argv[])
  30. {
  31.  
  32.    if( (argc < 2))
  33.      {
  34.      FILE *outfile;
  35.      char *name = "c:\\tc\\garbage\\printcol.dat";
  36.  
  37.       if ( (outfile = fopen(name, "w")) == NULL)
  38.           {
  39.           printf("some error has occured...\n");
  40.           status = BAD;
  41.           bye(status);
  42.            }
  43.        xprt(outfile);
  44.        fclose(outfile);
  45.        status = OK;
  46.        bye(status);
  47.      }
  48.      else
  49.       {
  50.  
  51.     if( (*argv[1] != 'p') && (*argv[1] != 'P'))
  52.      {
  53.          printf("\nusage is : %s  [p|P] (p being printing option)\n",argv[0]);
  54.          status = BAD;
  55.          bye(status);
  56.       }
  57.       else
  58.         {
  59.            xprt(stdprn);
  60.            status = OK;
  61.            bye(status);
  62.          }
  63.        }
  64.  
  65.  
  66. }
  67.  
  68. void xprt(FILE *name)
  69. {
  70.    int i;
  71.    fprintf(name,"\t\t\t\t%s\n", title);
  72.    for(i=0; i<=MAX; i++)
  73.      {
  74.     fprintf(name, "%02d EGA_\t\t\t\t\t%2d EGA_\n\n", i, i + 32);
  75.      }
  76.  
  77. }
  78.  
  79. void bye(int status)
  80. {
  81.  
  82.     if(status == OK)
  83.       {
  84.     clrscr();
  85.     printf("\nDone...");
  86.        }
  87.  
  88.     printf("\nBye bye from MEASoftlines...\n");
  89.     exit(status);
  90. }