Duplicates a file handle.
int _dup (int handle);
int dup (int handle);
Required Header |
<io.h> |
Return Value
Each of these functions returns a new handle to the currently open file. -1 indicates an error.
Parameters
handle
A handle to an open file
Remarks
The _dup function creates a new handle to the currently open file handle handle. Both the new handle and the old handle refer to the same file. Use _fileno to obtain the handle of a stream.
_dup is mostly used to duplicate the predefined handles for stdin, stdout and stderr before they are reassigned to other files.