用c语言编写一个设置密码的程序

如题所述

第1个回答  2020-01-07
#include
#include
typedef
struct
{
long
number;
//用户编号
6位
char
name[20];
//用户名
char
password[8];
//用户密码
int
power;
//权限判断
1
为管理员2为普通用户
}
user;
user
yh[100]={100000,"gavin","gavine",1,100001,"wnag","wangf",2};
int
length
=
2;
int
checkuser(long
num,
const
char
*nm,
const
char
*pwd)
{
int
i;
for
(i
=
0;
i
<
length;
++i)
{
if
(yh[i].number
==
num
&&
!strcmp(yh[i].name,
nm)
&&
!strcmp(yh[i].password,
pwd))
{
if
(1==yh[i].power)
return
1;
else
return
2;
}
}
}
void
main()
{
printf("%d\n",
checkuser(100000,
"gavin",
"gavine"));
}
相似回答
大家正在搜