Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.h)
ciso646 (iso646.h)
climits (limits.h)
clocale (locale.h)
cmath (math.h)
csetjmp (setjmp.h)
csignal (signal.h)
cstdarg (stdarg.h)
cstddef (stddef.h)
cstdio (stdio.h)
cstdlib (stdlib.h)
cstring (string.h)
ctime (time.h)
cstdio (stdio.h)
functions:
clearerr
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
fopen
fprintf
fputc
fputs
fread
freopen
fscanf
fseek
fsetpos
ftell
fwrite
getc
getchar
gets
perror
printf
putc
putchar
puts
remove
rename
rewind
scanf
setbuf
setvbuf
sprintf
sscanf
tmpfile
tmpnam
ungetc
vfprintf
vprintf
vsprintf
macro constants:
EOF
FILENAME_MAX
NULL
TMP_MAX
objects:
stderr
stdin
stdout
types:
FILE
fpos_t
size_t


tmpfile

function
<cstdio>
FILE * tmpfile ( void );

Open a temporary file

Creates a temporary binary file, open for update (wb+ mode -- see fopen for details). The filename is guaranteed to be different from any other existing file.
The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally.

Parameters

none

Return Value

If successful, the function returns a stream pointer to the temporary file created.
If the file cannot be created, NULL is returned.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
/* tmpfile example */
#include <stdio.h>
int main ()
{
  FILE * pFile;
  pFile = tmpfile ();
  // temporary file created. code here.
  fclose (pFile);
  return 0;
}


This code creates a temporary file and then deletes it closing the stream.

See also