Thread: Help with getch()

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    59

    Help with getch()

    Hi all,

    I am having problems getting getch() to work, what i want to do is
    at the end of my program ask the user if he wants to start again or quit, this is what i have :-


    Code:
    int endchoice()   
    {
    
    cout << "Type E to exit or press any other key to continue";
    finish = getch();
    
    if (finish == 'e')
    {
    return 0;
    }
    
    else
    {
    // does this need something?
    }
    
    }
    So what i am saying is if 'e' is pressed it should quit the program,
    any other key will return to main()

    When i enter 'e' it just returns to main() anyway?

    Can anyone see a problem?

    Thanks guys

    Boontune

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    59
    Ahaaa

    Got it!

    It just goes to show what you can learn when you mess about with your code...


    Thanks anyway guys

    Boontune

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Pls repair my basketball program
    By death_messiah12 in forum C++ Programming
    Replies: 10
    Last Post: 12-11-2006, 05:15 AM
  3. Pause a C program without getch()
    By swgh in forum C Programming
    Replies: 4
    Last Post: 02-20-2006, 11:24 AM
  4. Clearing input buffer after using getch()
    By milkydoo in forum C++ Programming
    Replies: 3
    Last Post: 07-21-2003, 11:04 PM
  5. Problems with getch()
    By GrNxxDaY in forum C++ Programming
    Replies: 14
    Last Post: 08-12-2002, 02:11 AM