home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / LCNOW2.ZIP / EXAMPLES / LIST_1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-03  |  562 b   |  35 lines

  1. /*
  2.  * L I S T _ 1
  3.  *
  4.  * Display the contents of an ASCII text file
  5.  * file on the user's screen. Bare-bones version.
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. int
  11. main(void)
  12. {
  13.     int ch;                 /* input character */
  14.     FILE *fp;               /* file pointer */
  15.  
  16.     /*
  17.      * Open the named file for reading.
  18.      */
  19.     fp = fopen("DOGGEREL.TXT", "r");
  20.  
  21.     /*
  22.      * Read the contents of the file and display
  23.      * each character as it is read.
  24.      */
  25.     while ((ch = fgetc(fp)) != EOF)
  26.         putchar(ch);
  27.  
  28.     /*
  29.      * Close the file.
  30.      */
  31.     fclose(fp);
  32.  
  33.     return (0);
  34. }
  35.