home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / ctutor / Examples / anyfile next >
Encoding:
Text File  |  1990-10-01  |  459 b   |  21 lines

  1. #include "stdio.h"
  2.  
  3. main()
  4. {
  5. FILE *fp1;
  6. char oneword[100],filename[25];
  7. char *c;
  8.  
  9.    printf("Enter filename -> ");
  10.    scanf("%s",filename);         /* read the desired filename */
  11.    fp1 = fopen(filename,"r");
  12.  
  13.    do {
  14.       c = fgets(oneword,100,fp1); /* get one line from the file */
  15.       if (c != NULL)
  16.          printf("%s",oneword);    /* display it on the monitor  */
  17.    } while (c != NULL);          /* repeat until NULL          */
  18.  
  19.    fclose(fp1);
  20. }
  21.