How do you tell a program to exit when you press a cetain button in C++
Printable View
How do you tell a program to exit when you press a cetain button in C++
#include <iostream.h>
main()
{
cout << "Hello World!" << endl;
return 0;
}
or:
cout << “Press ENTER to continue…”;
getch();
return(0);
}
When you say "button" do you mean "key" or a button as in a graphical interface (meaning you are doing Visual C++ )
Ammo
You should implement a kind of "event listener" .. a bit of code which looks after all the events in the sistem and runs continuously with your application, better as a separate thread. Then, when the keyboard is touched on the corresponding key, or the screen button is pressed -as U like- the listener will trigger the program exit (freeing the memory, closing all opened files, eventually closing used network connections, and so on).
Good luck!
BurnByThee, Why the heck did you post the same thread twice only with a different name? You could have and should have atleast given peaple time to post instead of being such a impatiant thread poster.