<ki********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi All,
I need a function that when user types a password in the console, the
password should be invisible (e.g. display nothing or display "*"
instead). Just as you can see when you login a machine.
How to implement this? Thanks!
Note: user is typing passord in the console.
Use whatever OS specific call you have to read a key from the keyboard. It
is different for each OS. Then get a keypress, and print "*" to the screen.
char Input;
std::string Password;
while ( Input = FunctionToGetKeypress() != 13 ) // 13 is usually enter
{
Password += Input;
std::cout << "*";
cout.flush(); // May or may not be needed
}
std::cout << std::endl;
for Windows it's getch()
Not sure for linux.
check for your OS what function it is to get a single key press.