Like Tree1Likes
  • 1 Post By DaveH

problem with while loop using getch function

This is a discussion on problem with while loop using getch function within the C++ Programming forums, part of the General Programming Boards category; Hey guys I'm writting a program that is supposed to play music and i'm having difficulty with turning the music ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    1

    problem with while loop using getch function

    Hey guys
    I'm writting a program that is supposed to play music and i'm having difficulty with turning the music on/off.

    To start the music the user has the press the O key, and to turn it off they press the M key, using on_off = getch(). The music is played by using the random function to select a midi_note, and then looped using the while loop.

    I can get the O button to start the loop, but then can't get the m button to stop it. I'm assuming this is because getch has already assigned O to the on_off.

    Is there a way around this? Sorry, but i'm a bit of a n00b when it comes to programming

    Thanks

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    213
    Without seeing what your code looks like, it will be almost impossible to answer.
    Rehman khan likes this.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    71
    Try getche() and see the pressed key, it should print O, M or whatever, if not then the bug prolly is in previous line

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getchar, getch and gets inside while loop
    By sampleandhold in forum C Programming
    Replies: 13
    Last Post: 03-31-2012, 04:18 PM
  2. Getch() like function
    By mr_raging_money in forum C Programming
    Replies: 3
    Last Post: 03-22-2012, 08:59 PM
  3. Problem with for loop calling external function
    By lordbubonicus in forum C Programming
    Replies: 2
    Last Post: 10-13-2007, 10:54 AM
  4. Making a getch and kbhit function?
    By Brian in forum C Programming
    Replies: 2
    Last Post: 03-03-2002, 10:50 AM
  5. Using getch() function
    By BigSter in forum C++ Programming
    Replies: 8
    Last Post: 12-03-2001, 10:05 AM

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