ferror() in C language | Detail

ferror( ) function in C language is basically used for deleting error from the stream(file).

ferror function in C
ferror() in C

Through this article we will be going to discuss ferror( ) function of C in detail in which we will cover following topics.

  1. ferror( ) function in c
  2. header file for ferror( ) function in c
  3. return value of ferror( ) function in c
  4. ferror( ) function in c syntax
  5. ferror( ) function in c program

ferror( ) function in C

The ferror( ) function is nothing but, it is a standard library function of C and it also called file handling function which is basically used to remove any error occurred  during read from the file or write on a file. 

Header file for ferror( ) function in C

This file function is define in <stdio.h> which is stand for standard input-output header file.

Return value of ferror( ) function in C

ferror( ) function return zero on success and if error occur than it returns non zero value.

Syntax of ferror( ) function in C

int ferror(FILE *pointer):

Example of ferror( ) function in C

#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fptr;
int Ch;
fptr=fopen("test","w");
Ch=getc(fptr);
if(ferror(fptr))
{
printf("Error in read operation\n");
exit(1);
}
else
printf("%c",Ch);
fclose(fptr);
return 0;
}

____________________________________

ferror function example in c

____________________________________

Conclusion:

ferror( ) function in C language is basically used for deleting error from the stream(file).

Post a Comment (0)
Previous Post Next Post