From: phreadd AT powerup DOT com DOT au (David Orme) Newsgroups: comp.os.msdos.djgpp Subject: Re: writing a program that reads .txt files Date: 13 Jun 1997 11:23:57 GMT Organization: Power Up Lines: 43 Message-ID: <5nrakd$10u$1@grissom.powerup.com.au> References: <5nodkk$h34$1 AT grissom DOT powerup DOT com DOT au> Reply-To: phreadd AT powerup DOT com DOT au NNTP-Posting-Host: ts1514.powerup.com.au Mime-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 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 | |