编写代码实现,模拟用户登录情景,并且只能登录三次

#include
/*编写代码实现,模拟用户登录情景,并且只能登录三次。
(只允许输入三次密码,如果密码正确则提示登录 成,如果三次均输入错误,则退出程序。
*/
int main()
{
int count = 3;
while (count !=0)
{
//注:注意数组越界问题
char pwd[7] = { 0 };//0 ‘0’ ‘\0’ null
scanf("%s",pwd);
if (strcmp(pwd,“123456”)==0)
{
printf(“登录成功\n”);
break;
}
count–;
printf(“您还有%d次机会\n”,count);
}
return 0;
}

你可能感兴趣的:(C语言)