I\'m trying to create a temporary text file in C++ and then delete it at the end of the program. I haven\'t had much luck with Google.
Could you tell me which funct
Well, assuming you have been successful in creating the temporary file, you can use the remove function to delete it.
The function is declared in stdio.h -
#include
int remove(const char *pathname);
For example, if you want to delete a file named myfile.txt the code will be
#include
int main()
{
if(remove("myfile.txt") == -1)
{
fprintf(stderr,"Remove failed");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
I hope by now, you already know how to create the temp file, so this should resolve your query. Hope it helps.