C语言做一个简易的登陆验证(功能)界面

C语言做一个简易的登陆验证(功能)界面,第1张

登陆验证

账号:admin

密码:123456 

#include
#include//gotoxy
#include//getch
#include//strcmp
#define ROW 14
#define COL 14

void gotoxy(int x,int y)//形参
{
	HANDLE hOut;
	COORD pos= {x,y};
	// 光标的起始位(第1列,第3行) 0是第1列 2是第3行
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut, pos);
	//printf("定位光标位置搜索(%d,%d)\n",pos.X,pos.Y);
}

void paintWindow()       //用户登录窗口
{
	int startX=6;
	int startY=5;
	int width=20;
	int height=20;
	int i=0;
	//打印顶部   
	//光标定位 找规律 ┗  ┛ ┏ ┓ ┃ ━
	//顶部 y不变 x 在变 (x-x+w)
	gotoxy(startX,startY);
	printf("┏");
	for(i=0;i0||i==8)  //长度最多八位
		{
			break;
		}
		if(ch>='0'&&ch<='9' || ch>='a'&&ch<='z'|| ch>='A'&&ch<='Z')
		{
			putch(ch);
			name[i]=ch;
			++i;
		}	
	}

	gotoxy(18,16); //光标定位在密码输入的位置
	i=0;//使用同一个计数器 需要重置
	//密码输入 存储
	while(1)
	{
		ch=getch();
		if(ch=='\r'&&i==0)  //任何内容都没输
		{
			continue;
		}
		if(ch=='\r'&&i>0||i==8)  //长度最多八位
		{
			break;
		}
		if(ch>='0'&&ch<='9' || ch>='a'&&ch<='z'|| ch>='A'&&ch<='Z')
		{
			putch('*');
			pwd[i]=ch;
			++i;
		}	
	}
	
    gotoxy(15,18);  //显示登录成功 登录失败
	if(strcmp(name,"admin")==0&&strcmp(pwd,"123456")==0)
	{
		printf("登录成功\n");
	}
	else
	{
		printf("登录失败\n");
	}

	gotoxy(0,27);
	
  //登录验证  admin 123456
}

int main()
{	
    login();
	return 0;	
}

结果:

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/607813.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-14
下一篇 2022-04-14

发表评论

登录后才能评论

评论列表(0条)

保存