execute function if user closes console

hello i would like to implements something in my code that clears the value of my variables when the user closes the console. could someone tell me how to do that or the program clears the values automatically?
Do you want it to free all the memory used by the program at termination? I am pretty sure that is done automatically... Otherwise, there are things you can look into; Win32 API. It gives you SO much more control over anything and everything about your windows (and much much more). That assuming you are using a Windows computer though... It will allow you to run a function when the [X] button is pressed on your window.

- Kyle
oh okay. i am going to try to learn the win32 API thanks for the answer.
What about using a destructor? I'm not sure if it's the console which is running your problem (in which case, just put it in the destructor of a global object). If the console is "owned" by some object, then just delete the object when that console is closed.
Topic archived. No new replies allowed.