3.2.11. fopen

Opens a file for reading, writing, or both.

Syntax

int fopen (fileid, file_name, mode)
int fileid;
char *file_name;
char *mode;

where:

fileid

An ID number for the file that is opened. This must be a user-defined fileid.

file_name

A string pointer identifying the name of the file you want to open. If you specify a hardcoded filename you must enclose it in double quotation marks. See Rules for specifying filenames for details on how to specify filenames that include a path.

mode

Standard C-style file mode.

Description

This macro opens a file for reading, writing, or both.

Return value

int

One of the following:

-1

Failure

fileid

Success, the ID number of the opened file is returned.

Rules for specifying filenames

Follow these rules when specifying a filename:

  • Filenames must be in double quotation marks, for example "myfiles/file".

  • Filenames containing a backslash must be in double quotation marks, with each backslash escaped. For example, "c:\\myfiles\\file".

Example

Example shows you how to use fopen in a macro.

See also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0175N
Non-ConfidentialID052111