How to hide input in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to hide input in c++

I want to create an password type input, but how do you hide the text you have entered?

6th Nov 2016, 12:32 PM
Chinmay Bhale
Chinmay Bhale - avatar
7 Answers
+ 2
int getch(void) Reads a character directly from the console without buffer, and without echo so use getch instead of cin
6th Nov 2016, 12:47 PM
Vamsi Varun
Vamsi Varun - avatar
+ 1
ok I think I got it, thanks!
6th Nov 2016, 12:57 PM
Chinmay Bhale
Chinmay Bhale - avatar
+ 1
char a[10],ch; for(int I=0;I<10;I++) { ch=getch(); a[I]=ch; }
6th Nov 2016, 1:00 PM
Vamsi Varun
Vamsi Varun - avatar
0
ok, how do you use it? can you show a small code?
6th Nov 2016, 12:52 PM
Chinmay Bhale
Chinmay Bhale - avatar
0
just for example
6th Nov 2016, 1:01 PM
Vamsi Varun
Vamsi Varun - avatar
0
you could just directly do a[I] = getch();
6th Nov 2016, 1:07 PM
Chinmay Bhale
Chinmay Bhale - avatar
0
C++ hide in put passowrd
7th Oct 2020, 5:31 AM
HaNad Germny
HaNad Germny - avatar