C++ examples for File Stream:File Operation
Delete the file specified by the user.
#include <stdio.h> #include <iostream> using namespace std; void main()/*from w w w . ja v a 2 s.c om*/ { char filename[12]; cout << "What is the filename you want me to erase? "; cin >> filename; if (remove(filename) == -1) { cout << "\n*** I could not remove the file ***\n"; } else { cout << "\nThe file " << filename << " is now removed\n"; } return; }