How do you use the function case, where right when you press the button it goes to that spot
How do you use the function case, where right when you press the button it goes to that spot
Code:#if _emo #define stereo_type_i_dislike #endif
That's not very descriptive, but from what I can tell, you're talking about when someone presses a key, it calles a function.
use this if that IS the case. (If not, I don't care):
#include <conio.h>
void main(void)
{
getch(variable_name);
/* then use if statements to determine where, when, and if to go, depending on the value of variable_name. This function will automatically take just 1 character, and then close the input stream. */
}
Hope this helped. And if it didnt? I don't care.
Sean Mackrory
[email protected]
Here's one way:
Use getche() if you want the input echoed.Code:#include <conio.h> #include <iostream.h> int main() { int answer; answer = getch(); switch(answer) { case 'a': cout << "User entered a.\n"; break; case 'b': cout << "User entered b.\n"; break; //add more cases as necessary default: //default condition cout << "Not found.\n"; } return 0; }
Last edited by swoopy; 11-05-2001 at 06:26 PM.