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:

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 ) :

	putc(info, fp);
		printf("File Error..!!\n");
		printf("Press any key to exit..\n");

C Online Test

« Previous Function Next Function »

Like/Share Us on Facebook 😋