tmpfile
Go Up to stdio.h Index
Header File
stdio.h
Category
Input/output Routines
Prototype
FILE *tmpfile(void);
Description
Opens a "scratch" file in binary mode.
tmpfile creates a temporary binary file and opens it for update (w + b). If you do not change the directory after creating the temporary file, the file is automatically removed when it is closed or when your program terminates.
Return Value
tmpfile returns a pointer to the stream of the temporary file created. If the file cannot be created, tmpfile returns NULL.
Example
#include <stdio.h> #include <process.h> int main(void) { FILE *tempfp; tempfp = tmpfile(); if (tempfp) printf("Temporary file created\n"); else { printf("Unable to create temporary file\n"); exit(1); } return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |
+ |
+ |
+ |