[Previous]
[Contents]
[Next]

tmpfile()

create a temporary binary file

Synopsis:

#include <stdio.h>
FILE *tmpfile( void );

Description:

The tmpfile() function creates a temporary binary file that's automatically removed when it's closed or when the program terminates. The file is opened in update mode.


Note: When a stream is opened in update mode, both reading and writing may be performed. However, writing may not be followed by reading without an intervening call to the fflush() function, or to a file-positioning function (fseek(), fsetpos(), rewind()). Similarly, reading may not be followed by writing without an intervening call to a file-positioning function, unless the read resulted in end-of-file.

Returns:

A pointer to the stream of the file created. If the file can't be created, tmpfile() returns NULL. When an error has occurred, errno indicates the type of error detected.

Examples:

#include <stdio.h>

static FILE *TempFile;

void main()
  {
    TempFile = tmpfile();

    /* ... */

    fclose( TempFile );
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

errno, fopen(), freopen(), tmpnam()


[Previous]
[Contents]
[Next]