tmpfile : tmpfile « stdio.h « C Tutorial






ItemValue
Header filestdio.h
DeclarationFILE *tmpfile(void);
Functionopens a temporary binary file for read/write operations and returns a pointer to the stream.
Returnreturns a null pointer on failure.


The temporary file created by tmpfile() is automatically removed when the file is closed or when the program terminates.

You can open TMP_MAX temporary files (up to the limit set by FOPEN_MAX).

#include <stdio.h>

int main(void){
  FILE *temp;
  if((temp=tmpfile())==NULL) {
    printf("Cannot open temporary work file.\n");
    exit(1);
  }
}








22.37.tmpfile
22.37.1.tmpfile