How can i write a program that will delete a certain file or set of files every time i run it?

I was wondering how i can write a program that will delete a certain file or set of files every time i run it? For example if the file was C:\users\Me\Desktop\Delete.txt how would i code a program to perform this delete operation?
Thanks in advance
you can do something like this :

c++ version :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <cstdio>
#include <iostream>

const char g_szFileName[] = "C:\\error.txt";

int main ()
{
    std::cout << "Press any key to delete " << g_szFileName;
    std::cin.get();

    if ( remove ( g_szFileName ) == 0 ); // remove is defined in cstdio
        std::cout << "\nSuccess !";
    else std::cout << "\nError in deleting";
    
    return 0;
}
Last edited on
Topic archived. No new replies allowed.