C getc() function : <stdio.h>

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)


Video from www.c4learn.com : Step by Step Debugging