I'm playing around with mkstemp(), which provides a file descriptor, but I want to generate formatted output via fprintf(). Is there an easy way to transform the file descriptor provided by mkstemp() into a FILE * structure that is suitable for use with fprintf()?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
FILE* f = fdopen(d, "w");
man fdopen output:
There is no standard way of doing this (or the reverse) as the C Standard has nothing to say about file descriptors. Your specific platform may or may not provide such a mechanism.
Use
fdopen()
: