conio.h> no more...

So, linux doesn't have conio.h.

1. What function can I use to achieve the same results as _getch()?

2. What function can I use to achieve the same results as _kbhit()?

Thanks for the help.
IWishIKnew wrote:
So, linux doesn't have conio.h.
Modern compilers wouldn't be caught dead with this header.
Unix and Unix-like systems tend to deal with terminals.

getch/kbhit type calls come up from the Micro -> PC -> DOS tradition where you are programming a device with a keyboard (rather than a terminal).

That's why you have to think of I/O differently.
make one. Use a queue to catch keyboard presses and access the in order.

getch() ~ keyQueue.front/pop();
kbhit()~ keyQueue.size()>0
Interesting. Is this how most Linux GUI/Terminal - based programs are writeen in linux?

Also, do you think it would be prudent to acquire PDcurses?
Last edited on
closed account (S6k9GNh0)
PDcurses or Ncurses are both cross-platform although I believe Ncurses is more universally accepted because of its extensions.

Also, no, most Linux-based CLI programs are not based on curses or use interrupt events (directly anyways). Generally only those that needed to update the terminal (rather than append to it) including those that want a CLI-based GUI.

Topic archived. No new replies allowed.