#include stdio.h#include string.h#include Windows.h#include stdlib.hint main(){int i;char password[]={0}; //首先定义一个数组,先不在里面放入数据。...
#include <stdio.h>
#include <string.h>
#include <Windows.h>
#include <stdlib.h>
int main()
{
int i;
char password[]={0}; //首先定义一个数组,先不在里面放入数据。
for (i=1;i<=3;i++) //也可以使用
{
scanf ("%s",password); //通过SCANF函数进行输入值到数组
if(strcmp(password,"123456")==0) //用IF函数进行判断
{
printf("登陆成功\n");
break;
}
else
{
printf ("密码错误,请重新输入密码\n");
}
}
if (i==4)
{
system("cls"); //在下方引用了几个系统函数和休眠函数,让输入界面更加互动。
printf ("------------>");
Sleep(1000);
printf ("密码错误三次即将退出程序\n");
Sleep(1000);
system("cls");
}
return 0;
}
织梦狗教程
本文标题为:使用C语言判断密码是否正确,三次失败就退出,超详细教程!!
基础教程推荐
猜你喜欢
- C++实现ETW进行进程变动监控详解 2023-05-15
- [c语言-函数]不定量参数 2023-09-08
- 带你深度走入C语言取整以及4种函数 2022-09-17
- centos 7 vscode cmake 编译c++工程 2023-09-17
- 全面了解C语言 static 关键字 2023-03-26
- C语言实现宾馆管理系统课程设计 2023-03-13
- C++实战之二进制数据处理与封装 2023-05-29
- [C语言]二叉搜索树 2023-09-07
- C语言 详解字符串基础 2023-03-27
- C语言编程C++旋转字符操作串示例详解 2022-11-20
