std :: fstream does not provide file system operations; it only provides file operations.
You can use C stdio remove , which should work with most compilers:
#include <stdio.h>
int main ()
{
if( remove( "myfile.txt" ) != 0 )
perror( "Error deleting file" );
else
puts( "File successfully deleted" );
return 0;
}
source
share