C non-blocking keyboard input

前端 未结 10 932
说谎
说谎 2020-11-22 05:59

I\'m trying to write a program in C (on Linux) that loops until the user presses a key, but shouldn\'t require a keypress to continue each loop.

Is there a simple wa

10条回答
  •  日久生厌
    2020-11-22 06:30

    There is no portable way to do this, but select() might be a good way. See http://c-faq.com/osdep/readavail.html for more possible solutions.

提交回复
热议问题