我有一个在 MinTTY(cygwin 的 shell)下运行的程序,调用 GetConsoleMode
/SetConsoleMode
失败。 _getch
也会回显到控制台。这是一个没有绑定(bind)到 cygwin 环境的 native win32 应用程序,因此任何 cygwin 函数都没有了。如何关闭回显以便输入密码?
最佳答案
我基本上通过 popen
模拟了以下内容:
save_state=$(stty -g) /bin/echo -n "Account: " read acct /bin/echo -n "Password: " stty -echo read password # this won't echo stty "$save_state" echo "" echo account = $acct and password = $password Read more at http://www.askdavetaylor.com/how_to_read_password_without_echoing_c.html#Z3FtcTtMHe0gJdES.99
关于c - 如何在 MinTTY 下关闭 echo ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13575624/