ishant
ishant

Reputation: 1

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?

Upvotes: 0

Views: 328

Answers (2)

Will
Will

Reputation: 5537

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.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799150

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

Upvotes: 2

Related Questions