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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password check...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hey guys.. how can I make a password check with for example strcmp...?

I'm trying to make the program check if the user's input in an EditBox is the same as a predefined Password I would make.. :)
 

const PASSWORD[]="password";
if(strcmp(PASSWORD,<text from editbox>) == 0)
{
// valid
}
else
{
// invalid
}

matt
 
thanks man..

but how do I convert the Text in the EditBox so I can compare the two strings? I always get an error saying I cannot convert AnsiString to char.
 
thanks man..

but how do I convert the Text in the EditBox so I can compare the two strings? I always get an error saying I cannot convert AnsiString to char.
 
Add the .c_str() method to the AnsiString. Or if you have two AnsiStrings use the = sign.
Code:
char First = &quot;Equal&quot;;
String Second = &quot;NotEqual&quot;; // same as AnsiString
String Three = &quot;NotEqual&quot;;

// Use character array
if(strcmp(First,Second.c_str()) == 0)
{
      // valid
}
else
{
     // invalid
}

// Use String (AnsiStrings)
if(Second == Three)
{
      // valid
}
else
{
     // invalid
}
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
if(DM8->tblOperator->Seek(UserName) == false) {
Application->MessageBoxA(&quot;Invalid User or Password&quot;,&quot;&quot;,MB_OK);
AllowLogin = false;
}
else if(strcmp(Password.c_str(),DM8->tblOperatorPASSWORD->AsString.c_str())) {
Application->MessageBoxA(&quot;Invalid User or Password&quot;,&quot;&quot;,MB_OK);
AllowLogin = false;
}
else
AllowLogin = true;
DM8->tblOperator->Close();

Louie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top