Associates a file descriptor with a stream.
Compatibility:This function is compatible with the following targets:
|
ANSI
|
BeOS
|
EMB/RTOS
|
|
#include <unix.h>
FILE *fdopen(int fildes, char *mode);Parameters:
Parameters for this facility are:
#include <stdio.h>
#include <unix.h>
int main(void)
{
int fd;
FILE *str;
fd = open("mytest", O_WRONLY | O_CREAT);
/* Write to the file descriptor */
write(fd, "Hello world!\n", 13);
/* Convert the file descriptor to a stream */
str = fdopen(fd,"w");
/* Write to the stream */
fprintf(str, "My name is %s.\n", getlogin());
/* Close the stream. */
fclose(str);
/* Close the file descriptor */
close(fd);
return 0;
}
Result: File mytest has:
Hello world!
My name is Ron Liechty.
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000