Standard Library Functions in C

adplus-dvertising
tmpfile() Function
Previous Home Next

Description

The C library function, The tmpfile( ) function opens a temporary file for update and returns a pointer to the stream. The function automatically uses a unique filename to avoid conflicts with existing files. The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates.

Declaration

Following is the declaration for tmpfile() function.

FILE *tmpfile(void)

Parameters

none

Return Value

The tmpfile( ) function returns a null pointer on failure; otherwise it returns a pointer to the stream

Example

#include <stdio.h>

int main ()
{
   FILE *fp;

   fp = tmpfile();
   printf("Temporary file");

   /* you can use tmp file here */

   fclose(fp);

   return(0);
}

Output

Temporary file
Previous Home Next