I have a program that will create a simple txt file in the same directory as the compiled .exe:
ofstream output("myfile.txt", ios::binary | ios::trunc);
At the end of my program, I have this to remove it:
remove("myfile.txt");
Both of these work well, however, I want the file deleted if the user closes the cmd window unexpectedly, accidently, or they end the process.