how to delete a file using c++?

how to delete a file in c++
I already look here: http://www.cplusplus.com/reference/cstdio/remove/ but still don't unsderstand.
for example i want to delete a .exe or .txt file.
Try this:

#include <cstdio>
const char* file_to_delete = "c:\samplefile.exe"
std::remove(file_to_delete);


The user running the program should have permission to delete that file(be admin or so)...
Last edited on
You should also put some checks in to determine whether or not the file was actually deleted, and what to do in that case. The example on the page you referenced showed a good example of how to do that.
Topic archived. No new replies allowed.