How to use select() to read input from keyboard in C

后端 未结 3 1508
暗喜
暗喜 2020-12-31 16:55

I am trying to use select() to read keyboard input and I got stuck in that I do not know how to read from keyboard and use a file descriptor to do so. I\'ve been told to use

3条回答
  •  感情败类
    2020-12-31 17:25

    Perhaps, you want the way to peek keyboard input on "WINDOWS"? On windows, it can't get result from select() for STDIN. You should use PeekConsoleInput(). And use handle of stdin like following.

    hStdin = CreateFile("CONIN$", GENERIC_READ|GENERIC_WRITE, ...
    

    stdin may become pipe input. if so, you don't get any keyboard input.

    P.S. If you don't ask about Windows, Sorry much.

提交回复
热议问题