Computer Science, asked by smartabdurrahman321, 1 month ago

What are Error handling functions during I/O

operations?​

Answers

Answered by ananya12644
0

Answer:

While dealing with files,it is possible that an error may occur. This error may occur due to following reasons:

Reading beyond the end of file mark.

Performing operations on the file that has not still been opened.

Writing to a file that is opened in the read mode.

Opening a file with invalid filename.

Device overflow.

Thus, to check the status of the pointer in the file and to detect the error is the file. C provides two status-enquiry library functions

feof() - The feof() function can be used to test for an end of file condition

Syntax

feof(FILE *file_pointer);          

Example

if(feof(fp))

printf(“End of file”);

ferror() - The ferror() function reports on the error state of the stream and returns true if an error has occurred.

Syntax

ferror(FILE *file_pointer);     

Example

if(ferror(fp)!=0)

printf(“An error has occurred”);

Similar questions