fdopen

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);

Arguments

file_desc
The file descriptor returned by open, creat, dup, dup2, or pipe.
a_mode
The access mode indicator. Use one of the following character strings: "r", "w", "a", "r+", "w+", "rb", "r+b", "rb+", "wb", "w+b", "wb+", "ab", "a+b", "ab+", or "a+".

These access modes have the following effects:

The update access modes allow a file to be opened for both reading and writing. When used with existing files, "r+" and "a+" differ only in the initial positioning within the file. The modes are as follows:

Description

This 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. For more information, see Chapters 1 and 2.

Return Values
pointer  Indicates that the operation has succeeded. 
NULL  Indicates that an error has occurred. 


Previous Page | Next Page | Table of Contents | Index