开发者

Replace letters with stars in password field with gcc

How to put stars * in the password field when user enters password?

In turbo we can use getch() 开发者_如何学运维but it is not available in gcc.

What would you suggest?


You can use termios(3) to control various characteristics of the terminal, such as whether or not it echoes typed characters.


Use the tcsetattr(3) function. In your termios structure, you'll need to unset ICANON (canonical mode), and ECHO (character echo). Then you can read the characters from the input one at a time, outputting an asterisk after each character input.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜