Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password in c++ | Deleting a character after printing it

When we type password in websites ,we see * or . instead of characters.How can this be made possible with c++.Suppose I am trying to input password through stdin and at the same time I am storing it in a char array and deleting the character input by the user and outputing * instead.I think deleting the character is the trick here.But how do we delete a character after having printed it via stdout.


1 Answers

Read the key with _getch() (header <conio.h>), save/process it, and print '*' character instead of it. <conio.h> is available only on Windows afaik, though.

like image 55
TX_ Avatar answered Jan 21 '26 02:01

TX_