FILE * tmpfile ( void ); |
<cstdio> |
Open a temporary file
Creates a temporary binary file, open for update (wb+ mode -- see fopen for details). The filename is guaranteed to be different from any other existing file.
The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally.
Parameters
none
Return Value
If successful, the function returns a stream pointer to the temporary file created.
If the file cannot be created,
NULL is returned.
Example
/* tmpfile example */
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = tmpfile ();
// temporary file created. code here.
fclose (pFile);
return 0;
}
|
This code creates a temporary file and then deletes it closing the stream.
See also
fopen | Open file (function) |
tmpnam | Generate temporary filename (function) |