CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2008
    Posts
    45

    Unhappy a non blocking getch() ????

    I have a loop whose running time is really longe and I want to save my variables before the loop finishes if requested by the user, but I don't want to block (wait for user to answer), like I need a method to check after an iteration finishes if the user have enterd a spesific key (say 's') if yes then save if not then continue to the other iteration.

    now this can't be done by _getch() of cin since both will wait for the user to input something (i.e. is the user didn't press anything the execution will halt on them) so is there a function or a trick to just see if the user entered anything without halting for an input?

    if the idea is not clear tell me to clarify further

    any help will be appriciated

  2. #2
    Join Date
    May 2002
    Posts
    1,435

    Re: a non blocking getch() ????

    Is this a console app? Maybe the old _kbhit() DOS function is still available and you can check for a keyboard hit in your loop before calling getch().

    If it's a Windows app you should implement keyboard message handlers in your window.

  3. #3
    Join Date
    Oct 2008
    Posts
    45

    Re: a non blocking getch() ????

    its a console application, and how exactly do I check for a keyboard hit? (without waiting)

  4. #4
    Join Date
    Oct 2008
    Posts
    45

    Re: a non blocking getch() ????

    yes thanks _kbhit() works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured