#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++的IO流 2022-11-20
- c++动态内存管理详解(new/delete) 2023-03-04
- C++ std::function的用法详解 2022-11-25
- C++ 实现即时通信的示例代码(直接运行) 2023-04-09
- Qt QFrame的具体使用 2023-05-10
- c语言的联合体和枚举 2023-09-06
- Qt QTableWidget基本操作及使用 2023-01-05
- C# 调用FFmpeg处理音视频的示例 2023-03-24
- 利用Matlab绘制好看的旋转九边形 2023-03-18
- 深度解析C语言中数据的存储 2023-04-20
