In header <cstdio>:
int remove(const char* filename)
Probably too late for you by now, as you needed an answer urgently. I hope you had the sense to look up remove() in your C++ book, or do a Google search.
Anyway, how would I do that so it deleted the file at closing?
you can register a function that will be called when the program terminates with the atexit() function. this func could tehn call remove() on the file.