Mail Archives: djgpp/1997/06/12/17:26:12
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 <stdio.h>
>
>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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Raw text -