Terminate C++ program by user input

Hi,

I have written an exe that could run for hours. I want to add feature that if a user wants to terminate the program in a few minutes instead of waiting for hours, he could just press Ctrl-C and a clean-up function gets called, which cleans up heap memory and exits.

How exactly could this be done?

Thanks!
How do you get user input in your program?
By command line arguments. The program could run infinitely. But I'd like it to listen to Ctrl-C and if user presses Ctrl-C, then clean-up is called and program exits.
See http://www.yolinux.com/TUTORIALS/C++Signals.html for examples on handling the signal.
Topic archived. No new replies allowed.