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. Supported modes are listed in Table 2.1:

Table 2.1. Mode options for fopen()

Text modeBinary modeDescription
r rbOpen a text/binary file for reading
wwbCreate a text/binary file for writing. Previous contents, if any, are discarded.
aabOpen a text/binary file for update. Data is written at the end of the file.
r+ r+bOpen a text/binary file for reading.
w+w+bCreate a text/binary file for update. Previous contents, if any, are discarded.
a+a+bOpen or create text/binary file for update. Data is 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 a error message is displayed and 0 is returned.

Copyright © 2007-2011 ARM. All rights reserved.ARM DUI 0371J
Non-ConfidentialID051712