I am creating a Linux terminal program using C.
I am trying to make a two digit code address a array location.
I don’t want to have to hit enter after every two digit input, I want the input to just be sent to my buffer variable through scanf directly after to characters are entered.
I do not have a code sample, as i have no idea how to approach this.
Thanks for any help!
You’ve got two options, which solve the same problem in nearly the same way. The first is to use
stdbufwhen you run your program; the invocation is:Using that prevents
stdinfrom being line-buffered, and will let you usefread()or similar commands to retrieve input as it happens.The other is to put the terminal in raw mode. It’s well-described here. But the downside is that control characters are no longer dealt with. In your program, you