#include<string.h>
int main()//这个学到了strcmp的用法
{
int i = 0;
char password[20] = { 0 };
for (i = 0; i < 3; i++)
{
printf("请输入密码\n"); //数组名本身是地址,所以不用&取地址
scanf("%s", password); //strcmp比较成功功时返回0;也就是strcmp==0时,输入密码正确
if (strcmp(password, "123123") == 0)//字符串比较要用strcmp不能用==
{
printf("密码正确\n");
break;
}
/*else
{
printf("密码错误\n");
}*/
}
if (i == 3)
{
printf("密码错误\n");
}
return 0;
}