home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
ctutor2.zip
/
ANSWERS
/
CH10_2.C
< prev
next >
Wrap
Text File
|
1989-11-10
|
557b
|
32 lines
#include "stdio.h"
main()
{
FILE *infile;
char c, infilename[25], inputline[100];
int line = 1;
printf("Enter input file name ----> ");
scanf("%s",infilename);
infile = fopen(infilename,"r");
printf("%5d",line);
do {
c = fgets(inputline,100,infile); /* read a line */
if (c != NULL) {
printf("%5d %s", line, inputline);
line++;
}
} while (c != NULL);
fclose(infile);
}
/* Result of execution
(You will get a listing of the file on the monitor with line numbers)
*/