Help with getch()

This is a discussion on Help with getch() within the C++ Programming forums, part of the General Programming Boards category; Hi all, I am having problems getting getch() to work, what i want to do is at the end of ...

  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, 02: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-22-2003, 12:04 AM
  5. Problems with getch()
    By GrNxxDaY in forum C++ Programming
    Replies: 14
    Last Post: 08-12-2002, 03:11 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21