RAD Studio
ContentsIndex
PreviousUpNext
tmpfile

Header File 

stdio.h  

Category 

Input/output Routines 

Prototype 

FILE *tmpfile(void); 

Description 

Opens a “scratch” file in binary mode. 

tmpfile creates a temporary binary file and opens it for update (w + b). If you do not change the directory after creating the temporary file, the file is automatically removed when it’s closed or when your program terminates. 

Return Value 

tmpfile returns a pointer to the stream of the temporary file created. If the file can’t be created, tmpfile returns NULL. 

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(1);
   }
   return 0;
}

Portability

POSIX 
Win32 
ANSI C 
ANSI C++ 
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!