tmpfile
raw OCR
Opens a "scratch" file in binary mode.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
FILE *tmpfile(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
tmpfile creates a temporary binary file and opens it for update {w + b). The file is automatically removed when it's closed or when your program terminates.
tmpfile creates the temporary file in the directory defined by the TMP environment variable. If TMP is not defined, the TEMP environment variable is used. If neither TMP or TEMP is defined, tmpfile creates the files in the current directory.
Return value
tmpfile returns a pointer to the stream of the temporary file created. If the file can't be created, tmpfile returns null.
See also
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(l);
}
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/tmpfile/
· short form /3.1/tmpfile/