Current location - Loan Platform Complete Network - Big data management - What is the difference between fgetc() and getc()?
What is the difference between fgetc() and getc()?
fgetc():

Definition of the function

int fgetc(FILE * stream);

Description of the function

fgetc() reads a single character from the file referred to by the argument stream. If it reaches the end of the file and there is no data, it returns EOF.

Return Value

fgetc() returns the character read, and if it returns EOF, it reaches the end of the file.

getc():

Function: fetch characters from stream

Usage: int getc(FILE *stream);

Note: This function is declared as a macro by ISO C, so you can't pass it as a function pointer when you use it (there are some compilers that give it as a function too, to say otherwise). Its prototype is as follows #define getc(_stream) (--(_stream)->_cnt >= 0?0xff & *(_stream)->_ptr++ : _filbuf(_stream))

Additionally, in C, the function getc() is used to read from a file. fgetc) to read characters from a file. getc and fgetc are used in the same way. The call form of getc: ch=getc(fp); here fp is a file pointer; function function is to read a character from the file pointed to by the file pointer, and return it as a function value to the character variable ch.