#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
int main()
{
int i = 0;
char password[20] = {0};
for(i=0;i<3;i++)
{
printf("请输入密码:>");
scanf("%s",password);
//if(password == "123456")//==不能比较两个字符串是否相等,应该使用一个库函数-strcmp
if(strcmp(password , "123456") == 0)
{
printf("登陆成功");
break;
}
else
{
printf("密码错误\n");
}
}
if(i==3)
printf("三次密码都错误 请退出程序\n");
return 0;
}
标签:include,登录,int,密码,printf,三次,password From: https://blog.51cto.com/u_15916254/5956421