#include <stdio.h>
#pragma warning (disable:4996)
#include <windows.h>
int main()
{
char arr[] = "123456";
char password[] = { 0 };
int i = 1;
for (i = 1; i <= 3; i++)
{
scanf("%s", password);
if (strcmp(password, "123456") == 0)
{
break;
}
else
{
printf("密码错误,重新输入\n");
}
}
if (i == 4)
{
printf("退出系统\n");
}
else
{
printf("登陆成功\n");
}
system("pause");
return 0;
}
三次调试的程序结果: