cfunctionkbhit

Is it possible to program your own kbhit() in C?


I took a class of programming at my university and I am working on some program. I want to know if it is possible to program my own kbhit() function. And if it is possible to look, how kbhit() is coded.

The purpose is that I need to know how functions I use work.


Solution

  • Yes and no.

    C language has no notion of input and output. It relies on a standard library (essentially written in C) that in turn relies on system calls.

    Neither the standard library, nor the set of system calls common to Unix-like systems and Windows deal with non blocking system calls, so you have to call system specific ones.

    But again, you can call them easily from C language.