home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / learn / rdfile.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-03  |  490 b   |  23 lines

  1. /* RDFILE.C: Reads a file and prints characters to 
  2.  * the screen.  If you get "Error in opening file" try
  3.  * running wrfile.c before you run this again.
  4.  */
  5.  
  6. #include <stdio.h>
  7.  
  8. main()
  9. {
  10.    int c;
  11.    FILE *fp;
  12.  
  13.    if( fp = fopen( "c:\\testfile.asc", "rb" ) )
  14.    {
  15.       while( (c = fgetc( fp )) != EOF )
  16.          printf( " %c\t%d\n", c, c );
  17.       printf( "\nEnd of file marker: %d", c );
  18.       fclose( fp );
  19.    }
  20.    else
  21.       printf( "Error in opening file\n" );
  22. }
  23.