优质回答 回答者:贾会根
#include
#include
void main()
{
int i,flag1,flag2;
char name[20]="lushan",password[10]="123456";
char person[20],password1[10];
for(i=0;i!=3;)
{
printf("Please input the name:\n");
gets(person);
flag1=strcmp(person,name);
printf("Please input the password:\n");
gets(password1);
flag2=strcmp(password,password1);
if(flag1==0&&flag2==0)
{
printf("Pass successfully!");
break;
}
else
{
printf("You have enter the wrong name or password!\n");
i++;
}
}
}
-----------------------------------------------------------------
回答者:DUFan
#include "stdio.h"
#include
#include
main()
{
char code1[7];
char code2[7];
int i=0;
printf("please input password with six numbers:");
do{ code1[i]=bioskey(0);
printf("*");
}while(i++!=5);
code1[i]='\0';
printf("\n\nplease input password again:");
i=0;
do{ code2[i]=bioskey(0);
printf("*");
}while(i++!=5);
code2[i]='\0';
if(strcmp(code1,code2)==0) printf("\nYES");
else printf("\nerror");
getchar();
}
输入是3次的话自己加个循环哈;
呵呵
TAGS: 用户名密码