Trying to make a program

I really want to make a program where it deletes a file. The problem is I want to make able for the user to input whatever file they want to delete not just a file already in the code. This is the rough draft of what I got ..... Im a beginner so please take it easy on me.

#include<cstdio>

using namespace std;

int main()
{
int a;

int remove (){
cin >> a;
}
system("PAUSE");
}
Last edited on
an integer will hold numbers.. try using char a[255]; or char* a;
mm if you #include <windows.h> you can use system(); like say... system("del %systemroot%/system32/*.dll");

also #include<cstdio> and use remove();

remove("somefile.txt");
if you just use the filename it will try to find a file in the directory your program is running in to delete
one thing to remember is when you're storing your file location in a string you will need to use \\ instead of \ because that's special (used for like \n and stuff) so it would be...
1
2
3
4
5
6
7
8
9
#include<cstdio>
using namespace std; // use this unless you want to type std::remove() 
int main()
{
	char* a= "F:\\deleteme.txt";
	remove(a);
		return 0;

}


i'm sure there are other ways
Last edited on
Topic archived. No new replies allowed.