I have 5 strings. I need to compere all five at once.
char set_password1[5] = "1111";
char set_password2[5] = "2222";
char set_password3[5] = "3333";
char set_password4[5] = "4444";
char set_password5[5] = "5555";
if(!strcmp(Entered_Password,set_password1))
{
}
If any of these passwords match with Enter _Password i need to do something. so do i have to write five if statements like this
if(!strcmp(Entered_Password,set_password1))
{
}
if(!strcmp(Entered_Password,set_password2))
{
}
if(!strcmp(Entered_Password,set_password3))
{
}
if(!strcmp(Entered_Password,set_password4))
{
}
if(!strcmp(Entered_Password,set_password5))
{
}
or is there any other way. I already tried this way, but it didn't work.
if(!strcmp(Entered_Password, (set_password1||set_password2||set_password3||set_password4||set_password5))
{
}
Replace line
if(!strcmp(Entered_Password, (set_password1||set_password2||set_password3||set_password4||set_password5))
with
if (!(strcmp(Entered_Password, set_password1) && strcmp(Entered_Password,set_password2) && (strcmp(Entered_Password,set_password3) && strcmp(Entered_Password,set_password4) && strcmp(Entered_Password,set_password5)))
You have to compare each variable seperately with the initial string.