0

i'm working with dynamic memory allocation and i need to ensure the memory is cleared if a user manually closes the console window.

Is there a way i can call a function when the console window is manually closed?

Eduardo
  • 6,900
  • 17
  • 77
  • 121
  • 3
    In any case, when the application is closed, the memory used by it is cleared by OS automagically, so you don't have to worry about it. There might be an option to register some callback, but I'm not aware of the one. Furthermore, if there would be such an option, it would certainly be OS-specific (and in this case we need to know what's your OS). – Alexander Shukaev May 06 '13 at 20:07

1 Answers1

1

I think this may help you. SetConsoleCtrlHandler function. I have tested this function with windows. And for Linux systems check this function at_quick_exit I never tested this function.

Sanoob
  • 2,466
  • 4
  • 30
  • 38