...

View Full Version : need help with C++



Dladu
10-18-2007, 11:43 PM
Well im trying to in c++ get the input but dont echo it to the screen but display * instead, also if the backspace key is pressed then delete an astericks and if there is nothing there, beep at you. Also if you use the arrow keys or space bar it beeps at you and does not work as there can't be spaces in this input

I was trying to use getch in a loop before the input but I couldn't get that to work so I was thinking I probably need to make a function where I have no clue where to start inorder to make that happen :P

have this so far



fflush(stdout);
int z = 0, ch, first;
char password4[100];
while ((ch = getch()) && ch != '\n' && ch != '\r'
&& z < sizeof(password4) - 1)
{
if (ch == '\b' && z > 0)
{
cout << "\b \b";
fflush(stdout);
z--;
password4[z] = '\0';
}
else
{
if (z == 0 && ch == '\b')
{
if( ch == '\b')
{
cout << "\a";
}
}
first = 2;
if ( z > 0 || first == 2 && ch != '\b' )
{
cout << "*";
password4[z++] = ch;
}
}
}
cout << "\n\n";
password4[z] = '\0';

Dunna
10-24-2007, 05:00 AM
Simple, you just use SendKeys() to send a backspace to the screen followed by an asterick. You of course record the typed key beforehand and add it to the end of your password array.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum