Mail Archives: djgpp/1997/06/13/16:49:22
Sorry, actually there were a few syntax errors.
Lines 14, 23: fscanf("...
should be: fscanf(f,"...
Line 19: c!=EOF
should be: ch!=EOF
Line 20: prinf(...
should be: printf(...
When I compiled this program (at request) I had a problem with the EOF
constant. A quick change to make it use "feof(f)" instead gives the
following correct, working and tested code:
#include <stdio.h>
main()
{
FILE *f;
char ch;
f=fopen("c:/autoexec.bat","rt");
fscanf(f,"%c",&ch);
/* while not the end-of-file of f */
while(!eof(f)){
printf("%c",ch);
fscanf(f,"%c",&ch);
}
fclose(f);
return 0;
}
--
| David Orme <>< | |
| phreadd AT powerup DOT com DOT au | "Striving for Excellence" |
| powerup.com.au/~phreadd | |
- Raw text -