I'm writing a program in C++ under Linux that needs to wait for user to press a key. Considering the key pressed the program will go accordingly. So I must be able to recover the key code from a variable afterwards.
My bad.... without the Enter, of course. Actually is a small tree menu, with 4-5 options, and enter after every key is not too professional. It would be fantastic if you would also sugest some site/doc/manual where these specs are available. What is free on the net is extremely shallow. No info on how to use keyboard, mouse, soundcard or any other periferal in C. If you would be so kind to point me in the right direction, I will highly appreciate.
I haven't done this in awhile but the need to hit enter is a function of the shell not the C function. The shell fills the input buffer and holds onto it until an enter is pressed. Then it releases it to the C function. So you need to alter the function of the shell. You do this with stty in your startup script. You need to set your shell to raw. This will change a number of things so be careful. The shell is not like dos. In the shell you re running inside and interrupter, such as bash ( it's not command.com ). That's why shell scripts are so much more powerful the bat files. So checkout the man page for stty.