Next: , Previous: swscanf, Up: Stdio


4.64 tmpfile—create a temporary file

Synopsis

     #include <stdio.h>
     FILE *tmpfile(void);
     
     FILE *_tmpfile_r(struct _reent *reent);
     

Description
Create a temporary file (a file which will be deleted automatically), using a name generated by tmpnam. The temporary file is opened with the mode "wb+", permitting you to read and write anywhere in it as a binary file (without any data transformations the host system may perform for text files).

The alternate function _tmpfile_r is a reentrant version. The argument reent is a pointer to a reentrancy structure.


Returns
tmpfile normally returns a pointer to the temporary file. If no temporary file could be created, the result is NULL, and errno records the reason for failure.


Portability
Both ANSI C and the System V Interface Definition (Issue 2) require tmpfile.

Supporting OS subroutines required: close, fstat, getpid, isatty, lseek, open, read, sbrk, write.

tmpfile also requires the global pointer environ.