Fgetc function : get character from stream
What this function does ?
- Header File : Stdio.h
- fgetc gets a character from a stream
- fgetc returns the next character on the named input stream.
- 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
#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