home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_tutor / anyfile.c next >
C/C++ Source or Header  |  1995-02-27  |  459b  |  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.