tmpfile() - I/O Function

How is "tmpfile()" used in C++?


tmpfile() is an I/O function which is used to open temporary file for update which will be deleted when the stream closes. If the temporary file is created the function returns a stream pointer, otherwise NULL is returned.


FILE * tmpfile ( void );

Example :

#include <stdio.h>
int main ()
FILE * str = tmpfile ();
fclose (str);
return 0;

In the above example the opened temporary file will get closed when the stream "str" is closed.

C++ Tutorial

Ask Questions

Ask Question