Creates a temporary file.
Standard C Library (libc.a)
#include <stdio.h>
FILE *tmpfile ( )
The tmpfile subroutine creates a temporary file and opens a corresponding stream. The file is opened for update. The temporary file is automatically deleted when all references (links) to the file have been closed.
The stream refers to a file which has been unlinked. If the process ends in the period between file creation and unlinking, a permanent file may remain.
The tmpfile subroutine returns a pointer to the stream of the file that is created if the call is successful. Otherwise, it returns a null pointer and sets the errno global variable to indicate the error.
The tmpfile subroutine fails if one of the following occurs:
Item | Description |
---|---|
EINTR | A signal was caught during the tmpfile subroutine. |
EMFILE | The number of file descriptors currently open in the calling process is already equal to OPEN_MAX. |
ENFILE | The maximum allowable number of files is currently open in the system. |
ENOSPEC | The directory or file system which would contain the new file cannot be expanded. |