![]() Chapter Contents |
![]() Previous |
![]() Next |
| fgetc |
| Portability: | ISO/ANSI C conforming, UNIX compatible |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| IMPLEMENTATION | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <stdio.h> int fgetc(FILE *f);
| DESCRIPTION |
fgetc
reads a single character from the stream associated with the
FILE
object addressed by
f
and returns
the character.
| RETURN VALUE |
fgetc
returns the next input character, or
EOF
if no character can be read.
| IMPLEMENTATION |
fgetc
is implemented by an actual function call, not a built-in function, so it
is slower than
getc
. (However, less code
is generated.)
| EXAMPLE |
#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);
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.