Message-Id: <1.5.4.32.19970612212315.0068d800@dce03.ipt.br> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Thu, 12 Jun 1997 18:23:15 -0300 To: phreadd AT powerup DOT com DOT au, djgpp AT delorie DOT com From: Cesar Scarpini Rabak Subject: Re: writing a program that reads .txt files Precedence: bulk At 08:56 12/06/97 GMT, David Orme wrote: [snipped] >This will output a text file to the screen, like type.exe: > ><-------------------------BEGIN-----------------------------> > >#include > >main() >{ > FILE *f; > char ch; > > /* open the file, "rt" means "read, text" */ > /* if it doesn't work, it might require double */ > /* slashes. ie. "c://files//sample.txt" */ > 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; >} > ><------------------------------END--------------------------> > >Hope this helps. Have you tested this piece of code before posting here? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cesar Scarpini Rabak E-mail: csrabak AT ipt DOT br DME/ASC Phone: 55-11-268-3522 Ext.350 IPT - Instituto de Pesquisas Tecnologicas Fax: 55-11-268-5996 Av. Prof. Almeida Prado, 532. Sao Paulo - SP 05508-901 BRAZIL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~