In C programming the <stdio.h> tmpfile creates a binary temporary file different from any other existing file.The declaration of the function is given below.
FILE* -A pointer of FILE* type pointing to the temporary file created.If the temporary file cannot be created NULL is returned.
Some points to note:
i)The temporary file created is opened with “wb+” mode.
ii)The number of temporary files that can be opened simultaneously is given by ‘TMP_MAX‘ which must be at least 25.
iii)The temporary file is removed when the program terminates.
iv)If the temporary file is opened,when the program terminates whether the file is removed is implementation-defined.
A more exhaustive code example is given below.
int i=1 ;
if( ffile!=NULL )
fputs( “New string ” , fp ); //writting string to temporary file pointed by ‘fp’
printf(“Temporary file cannot be created”);
rewind( fp );
/*Accessing the content of the temporary file */
while( ( i=fgetc(fp)) !=EOF )
fclose(fp); //closes the temporary file