Thread: Case 1, Case 2, Case 3........

  1. #1
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001

    Case 1, Case 2, Case 3........

    How do you use the function case, where right when you press the button it goes to that spot
    #if _emo
      #define stereo_type_i_dislike

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    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)
    /* 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

  3. #3
    Registered User
    Join Date
    Oct 2001
    Here's one way:
    #include <conio.h>
    #include <iostream.h>
    int main()
       int answer;
       answer = getch();
          case 'a':
             cout << "User entered a.\n";
          case 'b':
             cout << "User entered b.\n";
          //add more cases as necessary
             //default condition 
             cout << "Not found.\n";
       return 0;
    Use getche() if you want the input echoed.
    Last edited by swoopy; 11-05-2001 at 06:26 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Format Precision & Scale
    By mattnewtoc in forum C Programming
    Replies: 1
    Last Post: 09-16-2008, 10:34 AM
  2. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 01:11 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Converting Numbers to Words
    By denizengt in forum C Programming
    Replies: 20
    Last Post: 11-05-2003, 09:19 PM
  5. returning to a spot in the code
    By Shadow in forum C Programming
    Replies: 4
    Last Post: 09-22-2001, 05:24 AM