cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : C Library : cstdio (stdio.h) : tmpfile
 
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.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
FILE * tmpfile ( void );
<cstdio>

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

/* 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

fopen Open file (function)
tmpnam Generate temporary filename (function)
© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us