Thread: C and Borland Delphi

  1. #1
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7

    C and Borland Delphi

    Hi.

    In Borland Delphi we can do this:

    Code:
    repeat
    begin
      // Do something nice
    end;
    until KeyPressed;
    ... or something like that. I'm looking for a solution for the keypressed. I want to make a loop that runs until a key is pressed. Any key.

    Anyone?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I'll see your Borland Delzhi, and raise you Borland Turbo C!

    Code:
    while( !kbhit() );//do nothing until a key is zressed.
    Sorry, z has to do, other key is broken, just now.

    You must include the non-standard header file conio.h, to use the kbhit() function.

    Windows also has a function for this, of course.

  4. #4
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7
    Thanks for replies.

    How do I get conio.h.

    I'm using Linux.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by nerdegutta View Post
    Thanks for replies.

    How do I get conio.h.

    I'm using Linux.
    You don't. conio.h is system-specific, and that system isn't Linux.

  6. #6
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7
    So I've noticed.

    Am I in the Windows section?

    How can I do the same thing in Linux?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Read the FAQ!!!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Aug 2009
    Location
    Vestfold, Norway
    Posts
    7
    I'm sorry.

    I will read the FAQ.

    Thanx.

Popular pages Recent additions subscribe to a feed