C++ examples for File Stream:File Operation
Deleting or Renaming a File
#include <iostream> #include <cstdio> #include <cerrno> using namespace std; int main(int argc, char** argv) { if (remove("main.cpp") == -1) { // remove() returns -1 on error cerr << "Error: " << strerror(errno) << endl; return(EXIT_FAILURE); }/*ww w .j a va 2s .c om*/ else { cout << "File '" << argv[1] << "' removed." << endl; } }