What are the different modes available for opening a file in C?

Modes Description
“r” It opens a file in read mode for reading. File to read must exist.
“r+” It opens a file for both reading and writing. File must exist.
“w” It opens a file in write mode for writing. A file is created if it does not but if it exists its contents are overwritten
“w+” Open a file for both reading and writing. A file is created if it does not exist but if it exists its contents are overwritten.
“a” It opens a file in append mode. It adds the contents at the end of file.
“a+” Opens a file for both reading and appending.

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.