my assignment required us to enter password, but no matter what i do still cannot make it, any one can help me and modified my program?
void staff_password()
{
char password[10];
printf("Please Enter Password : ");
fflush(stdin);
scanf(" %[^\n]", password);
if(password != "user123")
{
printf("Invalid Password\n");
}
else
{
printf("Pass");
}
}
Last edited on
%[^\n] is same as %s
but i also try using %s also cannot, same problem, the result always "Invalid Password"
Oh, sorry. I didn't notice the rest. You can't compare strings using relational operators. You have to use strcmp().
oh... i remember this strcmp() in my 1st chapter, but i quiet not familiar with this strcmp(), can you help me?
i solve my problem, thank alot ^^
Last edited on