I need to read a password from standard input and wanted std::cin not to echo the characters typed by the user...
How can I disable the echo from std::c
If you don't care about portability, you can use _getch() in VC.
#include
#include
#include
int main()
{
std::string password;
char ch;
const char ENTER = 13;
std::cout << "enter the password: ";
while((ch = _getch()) != ENTER)
{
password += ch;
std::cout << '*';
}
}
There is also getwch() for wide characters. My advice is that you use NCurse which is available in *nix systems also.