_rmtmp

Removes temporary files.

int _rmtmp( void );

Routine Required Header Compatibility
_rmtmp <stdio.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

_rmtmp returns the number of temporary files closed and deleted.

Remarks

The _rmtmp function cleans up all temporary files in the current directory. The function removes only those files created by tmpfile; use it only in the same directory in which the temporary files were created.

Example

/* 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 <= 3; 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() );
}

Output

Temporary file 1 was created
Temporary file 2 was created
Temporary file 3 was created
3 temporary files deleted

Stream I/O Routines

See Also   _flushall, tmpfile, tmpnam