tmpfile() – I/O Function

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 :

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.

Leave a Reply

Your email address will not be published. Required fields are marked *