Associates a file pointer with a file descriptor returned by an open, creat, dup, dup2, or pipe function. Format #include <stdio.h> FILE *fdopen (int file_desc, char *a_mode);
1 – Arguments
file_desc The file descriptor returned by open, creat, dup, dup2, or pipe. a_mode The access mode indicator. See the fopen function for a description. Note that the access mode specified must agree with the mode used to originally open the file. This includes binary/text access mode ("b" mode on fdopen and the "ctx=bin" option on creat or open).
2 – Description
The fdopen function allows you to access a file, originally opened by one of the UNIX I/O functions, with Standard I/O functions. Ordinarily, a file can be accessed by either a file descriptor or by a file pointer, but not both, depending on the way you open it.
3 – Return Values
pointer Indicates that the operation has succeeded. NULL Indicates that an error has occurred.