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.
精彩评论