C tmpfile()

The tmpfile() function opens a temporary binary file for the read/write operations and returns a pointer to the stream. The function automatically uses a unique filename to avoid conflicts with existing files.

tmpfile() Syntax

FILE *tmpfile(void);

The tmpfile() returns a null pointer on failure, otherwise returns a pointer to the stream

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

tmpfile() Example

Following c code creates a temporary working file:

FILE *temp;
	printf("Cannot open temporary work file..!!\n");

C Online Test

« Previous Function Next Function »

Like/Share Us on Facebook 😋