C getc() function

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Fgetc function : get character from stream

What this function does ?

  1. Header File : Stdio.h
  2. fgetc gets a character from a stream
  3. fgetc returns the next character on the named input stream.
  4. It is a function not macro (getc is a macro)

Return Value :

Event Return Value
On Error Returns Character read after converting it into integer without sign Extension
On Success EOF
On End of File EOF

C Program to Read File Character by Character : Fgetc Function


void main()
FILE *fp;
char ch;

fp = fopen("tmp.txt","r");

printf("Data inside File : ");

 ch = fgetc(fp);

 if(ch == EOF)


fOR MORE Watch:https://youtu.be/42TW9JWHypU