Header File
stdio.h
Category
Input/output Routines
Prototype
int fgetc(FILE *stream);
wint_t fgetwc(FILE *stream);
Description
Gets character from stream.
fgetc returns the next character on the named input stream.
Return Value
On success fgetc returns the character read after converting it to an int without sign extension. On end-of-file or error it returns EOF.
Example
#include <string.h> #include <stdio.h> int main(void) { FILE *stream; char string[] = "This is a test"; char ch; /* open a file for update */ stream = fopen("DUMMY.FIL", "w+"); /* write a string into the file */ fwrite(string, strlen(string), 1, stream); /* seek to the beginning of the file */ fseek(stream, 0, SEEK_SET); do { /* read a char from the file */ ch = fgetc(stream); /* display the character */ putchar(ch); } while (ch != EOF); fclose(stream); return 0; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
fgetc |
+ |
+ |
+ |
+ |
fgetwc |
|
+ |
+ |
+ |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|