Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I hide input characters in comand line, using c++

Status
Not open for further replies.

modwad

Programmer
Feb 8, 2004
1
US
Im trying to create an install script using c++ and i need to know how to hide characters or replace them with astericks on the comand line when a user is typing a pasword. Anyone know of any flags or functions i can use to do this. i'v looked through the library and had no luck. Plz help me out, im goin crazy.
 
this should help:
Code:
#include <conio.h>
#define ENTER 13

void main()
{
	char password[30] = {0};
	int i = 0;

	cprintf(&quot;Enter password: &quot;);

	while( ( password[i++] = getch()) != ENTER )
	{
		putch('*');
	}
	
	cprintf(&quot;\npassword: %s\n&quot;,password);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top