Read more about parameters of tmpfile in parameters section
The tmpfilefunction in C language Creates a temporary binary file that is automatically deleted when closed or the program terminates.
The tmpfile function creates a temporary binary file in update mode (wb+). This file is automatically deleted when it is closed or when the program terminates normally. The file is created in the directory determined by the TMP environment variable.
The tmpfilefunction takes 1
parameter:
•
void `none`: Indicates that the function takes no arguments.
Creates a temporary binary file that is automatically deleted when it is closed or the program terminates. The file is opened in binary update mode (`wb+`). Returns a pointer to the `FILE` object on success or `NULL` if the file cannot be created.
The tmpfile function return value :
Returns a pointer to the temporary file stream if successful, or NULL if an error occurred
Output
This example creates a temporary file, writes to it, reads from it, and then closes it (which automatically deletes the file).