2.1.1 fopen()

int fopen(string filename, string mode)
Open a file specified by filename (the parameter filename can contain a path) with the specified mode.

Table 2-1 Mode options for fopen()

Text mode Binary mode Description
r rb Open a text/binary file for reading.
w wb Create a text/binary file for writing. Previous contents, if any, are discarded.
a ab Open a text/binary file for update. Data are written at the end of the file.
r+ r+b Open a text/binary file for reading.
w+ w+b Create a text/binary file for update. Previous contents, if any, are discarded.
a+ a+b Open or create text/binary file for update. Data are written at the end of the file.
If successful, a handle to the file opened is returned which can be passed to other file I/O functions. If unsuccessful an error message is displayed and 0 is returned.
Non-ConfidentialPDF file icon PDF versionARM DUI0840C
Copyright © 2014, 2015 ARM. All rights reserved.