C语言简单登录验证实现
C语言简单登录验证实现
代码:
#include <stdio.h>
#include <stdlib.h>
#define USER_NAME "admin"
#define PASSWORD "admin"
int main()
{
int putin();
putin();
return 0;
}
int login(char userName[],char passWord[])
{
if(strcmp(userName,USER_NAME)!=0||strcmp(passWord,PASSWORD)!=0)
return 0;
return 1;
}
int putin(void)
{
int login(char[],char[]);
char userName[25],passWord[25];
printf("用户名:");
gets(userName);
printf("密码:");
gets(passWord);
if(login(userName,passWord))
{
printf("登录成功!\n");
printf("Hello world!\n");
}
else{
printf("登陆失败!\n");
putin();
}
return 0;
}
运行