writing a password in c++

can anyone tell me how I can read a password in my program without appearing in a screen?? I want it apear like this: *******
Last edited on
Hi, can you give us a little more information please - is this a console application, windows, .Net, etc. If it's not a console application then the compiler and windows control you are using (or thinking of using) are probably going to be needed.
hi, I am asking about c++ program, c++ source code. when we read a string from the keyboard the caharacters appears on the screens, I want to hide these characters when the user enter them. is there is any library function do that?? or how we can prgram it??
Are you trying to do this within a Windows GUI program, Qt GUI program, or console application? Are you trying to do this from UN*X, Windows/DOS, etc? The answer to your question depends upon which of the above you are trying to do.
I am working on microsoft visual c++ 6.0, I installed it on windows operating system, and I am writing on a cpp file (c++ source code) console application
Last edited on
Hi amalkarajeh,
Below is a piece of code.
Have a look Iff it works for U.


1
2
3
4
5
6
7
8
9
10
	int i = 0;
	char ch;
	char password[20];
	do
	{
		ch = getch();
		cerr<<"*";
		password[i++] = ch;
	}
	while(ch != '\r');
DipentduDas. That won't work if someone redirects the cerr stream.
Zaita,
Yes U r Right..
If someone redirects the cerr then it doesn't help.
But If no redirection is there then It helps out.

Similarly If someone redirects cout, then also the same will not be reflected!!!
Is there any other way to sort this out???
Topic archived. No new replies allowed.