Comment

Richard Moore

Unfortunately you've just built your own (equally insecure) equivalent to mktemp(). The returned file descriptor is already openned, allowing you avoid a race condition whereby someone else could create a file with the same name. You can create a file object from the fd with a call to fdopen.