fgetc() function in C

 fgetc() function in C

fgetc() 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

  1. fgetc() function in c
  2. header file for fgetc() function in c
  3. return value of fgetc() function in c
  4. fgetc() function in c syntax
  5. 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;
}

____________________________________

example of fgetc() function

____________________________________

Conclusion

fgetc( ) function basically used to read a character from the file that has been open in read mode.

Post a Comment (0)
Previous Post Next Post