create a temporary binary file
#include <stdio.h> FILE *tmpfile( void );
The tmpfile() function creates a temporary binary file that's automatically removed when it's closed or when the program terminates. The file is opened in update mode.
When a stream is opened in update mode, both reading and writing may be performed. However, writing may not be followed by reading without an intervening call to the fflush() function, or to a file-positioning function (fseek(), fsetpos(), rewind()). Similarly, reading may not be followed by writing without an intervening call to a file-positioning function, unless the read resulted in end-of-file. |
A pointer to the stream of the file created. If the file can't be created, tmpfile() returns NULL. When an error has occurred, errno indicates the type of error detected.
#include <stdio.h> static FILE *TempFile; void main() { TempFile = tmpfile(); /* ... */ fclose( TempFile ); }
ANSI
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
errno, fopen(), freopen(), tmpnam()