Removes temporary files.
#include <stdio.h>
int _rmtmp( void );
The _rmtmp function is used to clean up all the temporary files in the current directory. The function removes only those files created by tmpfile and should be used only in the same directory in which the temporary files were created.
The _rmtmp function returns the number of temporary files closed and deleted.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
/* TMPFILE.C: This program uses tmpfile to create a temporary file,
* then deletes this file with _rmtmp.
*/
#include <stdio.h>
void main( void )
{
FILE *stream;
char tempstring[] = “String to be written”;
int i;
/* Create temporary files. */
for( i = 1; i <= 10; i++ )
{
if( (stream = tmpfile()) == NULL )
perror( “Could not open new temporary file\n” );
else
printf( “Temporary file %d was created\n”, i );
}
/* Remove temporary files. */
printf( “%d temporary files deleted\n”, _rmtmp() );
}
Temporary file 1 was created
Temporary file 2 was created
Temporary file 3 was created
Temporary file 4 was created
Temporary file 5 was created
Temporary file 6 was created
Temporary file 7 was created
Temporary file 8 was created
Temporary file 9 was created
Temporary file 10 was created
10 temporary files deleted