我需要将用户输入的内容与我之前使用 strncpy 存储的内容进行比较...我知道 strncpy 部分有效,当我将输入与 puser-> 用户名等进行比较时遇到问题...
int admin_signIn(struct profile *puser)
{
int i=0;
for(i=0;i<3;i++)
{
strncpy((puser+i)->UserName, "admin", strlen("admin")+1 );
strncpy((puser+i)->Pwd, "password", strlen("password")+1 );
printf("Enter admin user name:");
fgets(input,10,stdin);
rewind(stdin);
printf("Enter admin password:");
fgets(input,10,stdin);
//printf("the password is %s", puser->Pwd);
if(strcmp((puser+i)->UserName, input)==0 && strcmp((puser+i)->Pwd, input)==0)
{
printf("The Administrator username and password is incorrect, please try again\n");
}
else
{
printf("the info is good\n");
}
}
printf("max number of attepmpts exceded, goodbye!");
}