Declaration:
unsigned long fdopen(long handle, char type[]);
Description
Associates a stream with a file handle.
obtained from creatdup, dup2, or open. The type of stream must match the mode of the opened handle. The type string used in a call to fdopen is one of the following values:
Value Description
r Open for reading only.
Create for writing.
a Append; open for writing at the end-of-file or create for writing, if the file does not exist.
r+ Open an existing file for update (reading and writing).
w+ Create a new file for update.
a+
To specify that the given file is being opened or created in the text mode, append t to the value of the type string (for example, rt or w+t).
Similarly, to specify the binary mode, append brb or w+b). If t or b is not given in the type string, the mode is controlled by the _fmode global variable. If _fmode is set to O_BINARY, then files will be opened in the binary mode. If _fmode is set to O_TEXT, then files will be opened in the text mode.
Note. The O_* constants are defined in file system.h.
•
|
output cannot be directly followed by input without intervening fseekor rewind;
|
•
|
input cannot be directly followed by output without intervening fseek, rewind, or an input that encounters the end-of-file.
|
Returned value
On successful completion, fdopen returns the unsigned long identifying the stream. In the event of error, it returns 0.
|