NAG CL Interfacex04acc (open)

Settings help

CL Name Style:

1Purpose

x04acc opens a file for reading, writing or appending, and returns an associated file identifier.

2Specification

 #include
 void x04acc (const char *filename, Integer mode, Nag_FileID *fileid, NagError *fail)
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.

None.

5Arguments

1: $\mathbf{filename}$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: $\mathbf{mode}$Integer Input
On entry: specifies whether the file is to be opened for reading, writing or appending.
${\mathbf{mode}}=0$
The file is to be opened for reading.
If filename is an empty string or null pointer then fileid becomes associated with standard input.
${\mathbf{mode}}=1$
The file is to be opened for writing.
If filename is an empty string or null pointer then fileid becomes associated with standard output.
${\mathbf{mode}}=2$
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: $0\le {\mathbf{mode}}\le 2$.
3: $\mathbf{fileid}$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: $\mathbf{fail}$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, ${\mathbf{mode}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0\le {\mathbf{mode}}\le 2$.
NE_NOT_APPEND_FILE
Cannot open file $⟨\mathit{\text{value}}⟩$ for appending.
Cannot open file $⟨\mathit{\text{value}}⟩$ for reading.
NE_NOT_WRITE_FILE
Cannot open file $⟨\mathit{\text{value}}⟩$ for writing.

Not applicable.

8Parallelism and Performance

x04acc is not threaded in any implementation.

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.

10.1Program Text

Program Text (x04acce.c)

None.

10.3Program Results

Program Results (x04acce.r)