home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / GENCSRC.ZIP / LIST.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  2KB  |  40 lines

  1. /* *************************************************************** */
  2. /* This program will read in any text file and list it on the      */
  3. /* monitor with line numbers and with page numbers.                */
  4. /* *************************************************************** */
  5.  
  6. #include "stdio.h"                     /* standard I/O header file */
  7. #include "io.h"                        /* file I/O prototypes      */
  8.  
  9. void open_file(int no,char *name);
  10. void open_print_file(void);
  11. void print_a_line(void);
  12. void top_of_page(void);
  13.  
  14. #define MAXCHARS 255                     /* maximum size of a line */
  15. FILE *file_point;                    /* pointer to file to be read */
  16. FILE *print_file_point;                      /* pointer to pronter */
  17. char oneline[256];                     /* input string buffer area */
  18.  
  19. main(number,name)
  20. int number;                 /* number of arguments on command line */
  21. char *name[];               /* arguments on the command line       */
  22. {
  23. char *c;                       /* variable to indicate end of file */
  24. char *point;
  25.  
  26.    point = name[1];
  27.    open_file(number,point);     /* open the file to read and print */
  28.    open_print_file();
  29.  
  30.    do {
  31.       c = fgets(oneline,MAXCHARS,file_point);     /* read one line */
  32.       if (c != NULL)
  33.          print_a_line();                         /* print the line */
  34.    } while (c != NULL);                      /* continue until EOF */
  35.  
  36.    top_of_page();                     /* move paper to top of page */
  37.    fclose(file_point);                           /* close read file */
  38.    fclose(print_file_point);                  /* close printer file */
  39. }
  40.