There is no portable way to do that, because by default input is line buffered and echoed at low level in current platforms (at least Windows and Unix-like systems).
There are ways not to use line buffered input or to use manual echo, but it will be platform dependent.
Under Linux for example, you could put input in non canonical mode (see man termios) : that would allow you to read data one char at a time (for example) with echo off, do the echo manually, do not echo the newline but process the input buffer (with sscanf
) after a newline.
Under Windows, you could use the function getch
(declared in conio.h
) to also get one character at a time without echo. And I have no idea on how to do that on a Mac.