The function may be called by the names: x04acc, nag_file_open or nag_open_file.
3Description
x04acc opens a file for reading, writing or appending and returns an associated file identifier. This function is intended for use by callers of certain functions in Chapters E04 and F12 which use the file identifier for input or output of data.
4References
None.
5Arguments
1: – const char *Input
On entry: the name of the file to be opened. As special cases, an empty string or null pointer may be used to associate fileid with standard input or standard output. See the description of mode below.
Constraint:
must contain a valid filename for the computer system being used.
2: – IntegerInput
On entry: specifies whether the file is to be opened for reading, writing or appending.
The file is to be opened for reading.
If filename is an empty string or null pointer then fileid becomes associated with standard input.
The file is to be opened for writing.
If filename is an empty string or null pointer then fileid becomes associated with standard output.
The file is to be opened for appending.
If filename is an empty string or null pointer then fileid becomes associated with standard output.
Constraint:
.
3: – Nag_FileID *Output
On exit: an identifier associated with the file to be read from, written to or appended to. This identifier will typically be passed to other NAG C Library functions.
4: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_INT
On entry, .
Constraint: .
NE_NOT_APPEND_FILE
Cannot open file for appending.
NE_NOT_READ_FILE
Cannot open file for reading.
NE_NOT_WRITE_FILE
Cannot open file for writing.
7Accuracy
Not applicable.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
x04acc is not threaded in any implementation.
9Further Comments
None.
10Example
This example illustrates how to open a file for
writing, write a line to the file using x04bac and close the file using x04adc. The file is then reopened, the line read back using x04bbc, and closed again.