I am writing a Linux CLI program. I need to get a password from the user and, obviously, I don't want the password to be echoed to the console.
There are several solutions available here, but they are all for plain C.
http://stackoverflow.com/questions/1786532/c-command-line-password-input
http://stackoverflow.com/questions/1754004/how-to-mask-password-in-c
http://stackoverflow.com/questions/1196418/getting-a-password-in-c-without-using-getpass-3
How can those be adapted for C++, using std::string instead of char[]?
What would be the most elegant C++ solution?