Thread: do while any key not pressed

  1. #1
    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
    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, 01: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, 10:00 AM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM