void __fastcall TConnectionSR232App::Button3Click(TObject *Sender)
{
Check();
}
void TConnectionSR232App::Check()
{
int CharCounter; /*The ASCII Value of the current character*/
int Counter = 0; /*The Length of the Password*/
const char CurrentPassword[] = "superman"; /*What do we have here?*/
char CollectedPassword[ 20 ]; /*The Entered Password*/
cout<<"Please Enter your Password: "<<endl;
while(CharCounter != 13) /*Loop unless enter has been pressed*/
{
CharCounter = getch(); /*Get input*/
if (CharCounter != 13) /*If it isn't enter*/
{
CollectedPassword[ Counter ] = (char)CharCounter; /*Assign the ASCII Character*/
} /*Continue...*/
if(CharCounter != 13)
{
clrscr(); /*Clear Screen- Password Protection Illusion*/
cout<<"Please Enter your Password: "<<endl;
for(int StarCounter = 0; StarCounter != (Counter+1); StarCounter++) /*Loop for printing out Stars*/
{
printf("*");
}
Counter++; /*Increment Counter for Array*/
}
}
for(int X = 0;X!=(sizeof(CurrentPassword)-1);X++)
{
if(CollectedPassword[X]!=CurrentPassword[X])
{
goto Break;
}
}
cout<<"\nPassword Correct\n"<<endl; /*Success*/
// return 0;
Break:
cout<<"\nWrong Password\n"<<endl;
//return 0;
}
Partager