do while any key not pressed

This is a discussion on do while any key not pressed within the C Programming forums, part of the General Programming Boards category; Hi guys! How should I do to stop a for statement if ESC key is pressed? thank you guys!...

  1. #1
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52

    do while any key not pressed

    Hi guys!
    How should I do to stop a for statement if ESC key is pressed?

    thank you guys!

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    I use windows and an DOS compiler.. so i would code it like this.... please not this code may not compile on all compilers


    Code:
    # include <conio.h>
    
    
    int main()
    {
    
    
    char ch=' ';
    
    while(ch!=27)
    {
    
    //do something
    
    
    if(kbhit())
    ch=getch();
    
    }
    
    return 0;
    }

  3. #3
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52
    thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. need help program crashing
    By tunerfreak in forum C++ Programming
    Replies: 14
    Last Post: 05-22-2006, 11:29 AM
  3. Function to check memory left from malloc and free?
    By Lechx in forum C Programming
    Replies: 4
    Last Post: 04-24-2006, 05:45 AM
  4. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM

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