Mail Archives: djgpp/1998/10/21/20:57:05.3
Miguel Guerreiro,bioquimica wrote:
>
> I'm trying to write a program that reads one character at a time from a
> text file
> the problems is that it either reads it from the keyboard or doesn't do
> anything.
General C questions are better posted to comp.lang.c, but since you're
here...
Use something like:
#include <stdio.h>
FILE *f;
int c; /* Not `char'; `EOF' is outside the range of a `char'. */
f = fopen(filename, "r"); /* for "r"ead */
do {
c = getc(f);
if (c != EOF) do_something_with_character(c);
} while (c != EOF);
/* You've reached the end of the file */
fclose(f);
If that doesn't help, be specific about what you want to accomplish and
what you've tried.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -