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 :

EventReturn Value
On ErrorReturns Character read after converting it into integer without sign Extension
On SuccessEOF
On End of FileEOF

C Program to Read File Character by Character : Fgetc Function

#include<stdio.h>
void main()
{
FILE *fp;
char ch;
fp = fopen("tmp.txt","r");
printf("Data inside File : ");
while(1)
 {
 ch = fgetc(fp);
 if(ch == EOF)
    break;
 printf("%c",ch);
 }
getch();
}

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