How do I hide a password in switch case when inputed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I hide a password in switch case when inputed

C++

8th Mar 2020, 11:26 AM
Eddy
Eddy - avatar
4 Answers
+ 1
What does jkkk mean?
8th Mar 2020, 12:14 PM
HonFu
HonFu - avatar
0
I dosen't mean anything. I was just typing fast
8th Mar 2020, 5:12 PM
Eddy
Eddy - avatar
0
You can use a trick for that. Instead of cin you can do this. (if that's what you mean) string pass=""; char inp; do{ //get a new character every time the loop runs inp=cin.get(); //if Enter is pressed exit the loop if(inp=='\n')break; //filling the password incerted with the new character pass+=inp; //setting the cursor position at the start of the line cout<<"\r"<<endl; //replacing the characters that are followed with an asterisk for(int i=0;i<pass.length();i++) cout<<'*'<<endl; }while(true); ... You can use a backspace action too but I haven't anything that can help in my mind right now
9th Mar 2020, 9:56 PM
xaralampis_
xaralampis_ - avatar
0
Thanks
24th Sep 2020, 7:08 AM
Eddy
Eddy - avatar