Computer Science, asked by priya970576, 16 days ago

WAP that opens a file and writes data to it. Handle exceptions that can be generated during the 1/0 operations.

Answers

Answered by lokeshgajbhiye70
0

Explanation:

It is quite common that errors may occur while reading data from a file in C++ or writing data to a file. For example, an error may arise due to the following:

When trying to read a file beyond indicator.

When trying to read a file that does not exist.

When trying to use a file that has not been opened.

When trying to use a file in an inappropriate mode i.e., writing data to a file that has been opened for reading.

When writing to a file that is write-protected i.e., trying to write to a read-only file.

Failure to check for errors then the program may behave abnormally therefore an unchecked error may result in premature termination for the program or incorrect output.

Below are some Error handling functions during file operations in C/C++:

Answered by ankitapurkait91
0

Answer:

To create a file in a 'C' program following syntax is used, FILE *fp; fp = fopen ("file_name", "mode"); In the above syntax, the file is a data structure which is defined in the standard library. fopen is a standard function which is used to open a file.

Explanation:

Thank you

Similar questions