用do-while循环制作一个简单的登录验证功能

当用户输入用户名为:123和密码为:456时登录成功 否则重新登录。并且限制次数为三次,三次之后无权限登录。

第1个回答  2010-08-10
#include<stdio.h>
#include<string.h>
int main(void)
{
char name[] = "123";
char psd[] = "456";
char inname[32],inpsd[32];
int i = 1;
do
{
printf("please input your name:");
gets(inname);
printf("please input the password:");
gets(inpsd);
if(!(strcmp(name,inname) || strcmp(psd,inpsd)))
{
printf("login succeed\n");
return 0;
}
i++;
}while(i <= 3);
printf("you can't get into the system after the three times wrong name and password!\n");
return 0;
}本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网