fgetc() function in C
![]() |
| fgetc( ) function |
Through this article we will be going to discuss about fgetc( ) function of C in which we talk about following topics
- fgetc() function in c
- header file for fgetc() function in c
- return value of fgetc() function in c
- fgetc() function in c syntax
- fgetc() function in c program
fgetc( ) function in C
The fgetc() function is nothing but, it is also a standard library function of C which is basically used in file handling to read a single character from the file.
Header file for fgetc( ) function in C
This file function is define in <stdio.h> which is stand for standard input-output header file.
Return value of fgetc( ) function in C
fgetc( ) function return ASCII code of the character read by the function and it also return the character present at the position of the file pointer
Syntax of fgetc( ) function in C
int fgetc(int char , FILE *pointer):
Example of fgetc( ) function in C
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *p;
char ch;
if((p=fopen("myfile.txt","r"))==NULL)
printf("This file doesn't exist\n");
else
while((ch=fgetc(p))!=EOF)
{
printf ("%c",ch);
}
fclose(p);
return 0;
}
____________________________________
____________________________________
Conclusion
fgetc( ) function basically used to read a character from the file that has been open in read mode.

