C library functions - tmpfile ()
C standard library - <stdio.h>
description
C library functionsFILE * tmpfile (void) in binary update mode (wb +) create temporary files.Temporary files are created or when the program will be terminated automatically deleted when the stream is closed.
statement
The following is a statement tmpfile () function.
FILE *tmpfile(void)
parameter
- NA
return value
If successful, the function returns a pointer to the stream pointer temporary file is created. If the file is not created, it returns NULL.
Examples
The following example demonstrates tmpfile () function is used.
#include <stdio.h> int main () { FILE *fp; fp = tmpfile(); printf("临时文件被创建\n"); /* 您可以在这里使用临时文件 */ fclose(fp); return(0); }
Let's compile and run the above program, it creates a temporary file in / tmp folder, but once the program exits, the temporary files will be automatically deleted, and the program will produce the following results:
临时文件被创建