Eduardo
Eduardo

Reputation: 7141

Execute function on console close c++

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?

Upvotes: 0

Views: 1084

Answers (1)

Sanoob
Sanoob

Reputation: 2474

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.

Upvotes: 1

Related Questions