i need hepkl wiht two thigns i searhced hte board for and everything. 1. how do i have it so when the user presses the escape key the program automaticly shiuts itslef down during anytime of the program, and isnt the sleep code sleep (1000);
i need hepkl wiht two thigns i searhced hte board for and everything. 1. how do i have it so when the user presses the escape key the program automaticly shiuts itslef down during anytime of the program, and isnt the sleep code sleep (1000);
please, PLEASE:
1)look before you type each letter
2)if you're starting a numbered list, remember to include the number that comes after one
to answer your question:
exit(0);
and yes, sleep(1000); should work.
for the exit(0); i need it so as soon as you press esc the program shuts off
and when i used the slep command i get this eerror
implicit declaration of function `int sleep(...)'
i used this code on the line of the error
sleep (1000);
Last edited by Klinerr1; 07-15-2002 at 11:34 PM.
you might need to rewrite your program to do that. essentially, you need to check the keyboard buffer many times a second for the esc key, and use exit(0) when that happensfor the exit(0); i need it so as soon as you press esc the program shuts off
you probably forgot to include a header file. my suggestion is to look it up online, or you can do trial and error with most common header files.[/QUOTE]and when i used the slep command i get this eerror
implicit declaration of function `int sleep(...)'
Sleep() is a function in windows.h (make sure to include windows.h and also make sure that you are case sensative in calling the function). getch() is the function you are going to want to use for getting pressed keys. EXAMPLE:
Code:#include <iostream.h> #include <conio.h> #define ESC 27 int main() { char chartron; while(true) { if(kbhit()) chartron=getch(); if(chartron==ESC) return 0; } return 0; }