- C Programming Basics
- C Tutorial
- C Program Structure
- C Basic Syntax
- C Data Types
- C Constants
- C Variables
- C Operators
- C Ternary Operator
- C Storage Classes
- C Flow of Control
- C Decision Making
- C if if-else Statement
- C switch Statement
- C Loops
- C for Loop
- C while Loop
- C do-while Loop
- C goto Statement
- C break Statement
- C continue Statement
- C Popular Topics
- C Arrays
- C Strings
- C Pointers
- C Functions
- C Recursion
- C Scope Rules
- C Programming Advance
- C Structures
- C Unions
- C Bit Fields
- C Enumerations
- C Input & Output
- C Typedef
- C Preprocessors
- C Type Casting
- C Recursion
- C Error Handling
- C Linked Lists
- C Stacks
- C Queues
- C Binary Trees
- C Header Files
- C File I/O
- C Variable Arguments
- C Memory Management
- C Command Line Arguments
- C Programming Examples
- C Programming Examples
- C Programming Test
- C Programming Test
C ferror()
The ferror() function is used to check for the file error on given stream. A return value of zero indicates no error has occurred, whereas a non-zero value indicates an error occurred.
ferror() Syntax
Following is the syntax of the ferror() function:
#include<stdio.h> int ferror(FILE *stream);
Note : Use perror to determine the exact nature of error
ferror() Example
The following c program aborts program execution if a file error occurs ( Let's assume that fp points to a stream that opened fro write operations ) :
while(!done) { putc(info, fp); if(ferror(fp)) { printf("File Error..!!\n"); printf("Press any key to exit..\n"); getch(); exit(1); } }
« Previous Function Next Function »
Follow/Like Us on Facebook
Subscribe Us on YouTube