Mode Strings for fopen() - C File

C examples for File:File Operation

Introduction

Mode StringMeaning
"r" Open a text file for reading.
"w" Open a text file for writing, truncating an existing file to zero length, or creating the file if it does not exist.
"a" Open a text file for writing, appending to the end of an existing file, or creating the file if it does not exist.
"r+" Open a text file for both reading and writing.
"w+" Open a text file for reading and writing, first truncating the file to zero length if it exists or creating the file if it does not exist.
"a+" Open a text file for reading and writing, appending to the end of an existing file, or creating the file if it does not yet exist; the whole file can be read, but writing can only be appended.
"rb" , "wb" , "ab" , "ab+" , "a+b" , "wb+" , "w+b", "ab+" , "a+b" For binary file
"wx" , "wbx" , "w+x" , "wb+x" or "w+bx" Like the non-x modes, except they fail if the file already exists and they open a file in exclusive mode, if possible.

Related Tutorials