ferror( ) function in C language is basically used for deleting error from the stream(file).
![]() |
| 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.
- ferror( ) function in c
- header file for ferror( ) function in c
- return value of ferror( ) function in c
- ferror( ) function in c syntax
- 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;
}
____________________________________
____________________________________
Conclusion:
ferror( ) function in C language is basically used for deleting error from the stream(file).

