#include <stdio.h> int fgetc(FILE *f);
fgetc
reads a single character from the stream associated with the
FILE
object addressed by f
and returns the character.
fgetc
returns the next input character, or EOF
if no character can
be read.
fgetc
is implemented by an actual function call, not a built-in
function, so it is slower than getc
. (However, less code is generated.)
#include <stdio.h> main() { FILE *fp; int c,count; count = 0; fp = fopen("tso:MYFILE", "rb"); /* Open MYFILE to read. */ while ((c = fgetc(fp)) != EOF) /* Count characters. */ ++count; printf("Number of characters in the file "tso:MYFILE": %d", count); fclose(fp); }
getc
, getchar
, ungetc
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.