Thread: Specific while loop..

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    2

    Specific while loop..

    Hi,

    while(!kbhit()) function is that whenever a key is pressed the while loop end. How on earth do I make a specific key be assigned to do this? ex..the program only ends when esc is pressed?

    Thank you all

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well you can always figure the keystrokes out yourself. Call getch after the kbdhit triggers, storing the value in an int. Display the value with a printf line or what not. Run your program, press esc and see what value it displays. Then modify your loop to stop using the same method, if getch returns that value.

    Note, some keystrokes actually count as two key presses. For example, the F Keys. You read the first, then the second to see which one was struck. But most are a single stroke.

    Now that you have the know how, post some code when you're stuck and errors and all the good stuff as per the Announcements at the top of the forum.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My loop within loop won't work
    By Ayreon in forum C Programming
    Replies: 3
    Last Post: 03-18-2009, 10:44 AM
  2. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 12:38 PM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. A somewhat bizzare problem!!! - WHILE LOOP
    By bobthebullet990 in forum C Programming
    Replies: 3
    Last Post: 03-31-2006, 07:19 AM
  5. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM