home *** CD-ROM | disk | FTP | other *** search
- /* line-at-time file reader */
-
- #define MAXLEN 80
-
- main() /* fgets.c -- demonstrates use of fgets() */
- {
- FILE *fi;
-
- char source[25], line[MAXLEN], *p;
-
- printf("Input filename: ");
- gets(source);
- if((fi = fopen(source, "r")) == NULL) {
- printf("\tCan't open %s\n",source);
- exit();
- }
- p = line;
- while(p != NULL) {
- p = fgets(line,MAXLEN,fi);
- printf(line);
- }
- fclose(fi);
- puts("\n{DONE}");
- }