C programming stdio.h function - FILE *tmpfile(void)

www.i‮aeditfig‬.com

The tmpfile() function in the stdio.h library of C programming language creates a temporary binary file that is automatically deleted when it is closed or the program terminates.

The function has the following prototype:

FILE *tmpfile(void);

The tmpfile() function returns a pointer to a temporary file, opened in binary mode (i.e., the mode string "wb+"). If the function fails to create a temporary file, it returns a null pointer.

The temporary file is created with a unique name in the default temporary directory (as specified by the TMPDIR environment variable), and is automatically deleted when it is closed or the program terminates. The temporary file is opened in binary mode, which means that it can be read from and written to using binary input/output functions like fread() and fwrite().