C语言:编写程序输入密码校验三次

程序如下:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main()
{
char password[10] = { 0 };
int i = 0;
for (i = 0; i < 3; i++)
{
printf(“请输入密码:\n”);
scanf("%s", password);
if (strcmp(“123456”, password) == 0)
{
printf(“登录成功\n”);
system(“pause”);
return 0;
}
else
{
printf(“密码错误\n”);
}
}
printf(“退出程序\n”);
return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44779591/article/details/88897310