It depends on the platform.
If this is for Windows, the most direct access to the "keyboard buffer" is using WM_INPUT and GetRawInputData. See Using source input with a keyboard and mouse example.
Another DOS / Windows way is the conio.h of the getch () / kbhit () function.
The portable library is called Curses and has ports for Linux and Windows.
However, since you are targeting a specific OS, you need to check the documents for that OS.
The most direct platform-independent way is getchar / scanf / everything that is read from stdin, but stdin is a string buffer, so you wonβt get any data until the enter key is pressed. You can change the buffering settings, but again, it depends on the platform and may not be possible on any platform. See the related discussion of setbuf (stdin, NULL) .
source share