From: Andrew Crabtree Message-Id: <199706122220.AA008974031@typhoon.rose.hp.com> Subject: Re: writing a program that reads .txt files To: djgpp AT delorie DOT com Date: Thu, 12 Jun 1997 15:20:31 PDT Precedence: bulk > >This will output a text file to the screen, like type.exe: > > > ><-------------------------BEGIN-----------------------------> > > > >#include > > > >main() > >{ > > FILE *f; > > char ch; > > f=fopen("c:/files/sample.txt","rt"); > > /* read a char from the file */ > > fscanf("%c",&ch); ^^ > > /* is it the end of the file yet? */ > > while(c!=EOF){ ^ > > /* write the char to the screen */ > > prinf("%c",ch); > > /* read another character */ > > fscanf("%c",&ch); ^^ > > } > > /* close the file */ > > fclose(f); > > return 0; > >} > Have you tested this piece of code before posting here? Do you have one of those funny compilers that thinks that variable c is undeclared, and that fscanf needs its first argument to be a file pointer? ;) Or does it say use getch instead of fscanf. Andrew