I am using the following code to read and output each keystroke without having to press enter each time.
system("\bin\stty raw");
Right after I finish reading, the program does another system call to reset the terminal behaviour.
system("\bin\stty cooked");
The thing is, the last line is not resetting the terminal behavior as it should. Everything gets messed up once this program terminates. It continues to read input and does not do anything once an enter or CTRL C or anything else is pressed.
How can I reset the terminal behavior to the one it initially was please?