[英]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? 手动关闭控制台窗口时,有什么方法可以调用函数?
I think this may help you. 我认为这可能对您有帮助。 SetConsoleCtrlHandler function.
SetConsoleCtrlHandler函数。 I have tested this function with windows.
我已经用Windows测试了此功能。 And for Linux systems check this function at_quick_exit I never tested this function.
对于Linux系统,请在at_quick_exit上检查此功能,我从未测试过此功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.