C语言用c写一个可以验证账号,密码和修改密码的程序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言用c写一个可以验证账号,密码和修改密码的程序相关的知识,希望对你有一定的参考价值。
#include <string.h>struct e
char a[10];
char b[10];
z;
int main()
int t=0;
char s[10],d[10];
FILE *p;
void as();
if ((p=fopen("m.txt","r+"))==NULL)
p=fopen("m.txt","w+");
t=1;
if(t==1)
printf("当前没有任何用户\n");
printf("请新建用户名: ");
scanf("%s",s);
printf("为用户设置密码: ");
scanf("%s",d);
strcpy(z.a,s);
strcpy(z.b,d);
fprintf(p,"%s %s",z.a,z.b);
fclose(p);
if(t==0)
printf("请输入用户名: ");
scanf("%s",s);
fscanf(p,"%s %s",z.a,z.b);
fclose(p);
if (!strcmp(z.a,s))
printf("请输入密码:");
scanf("%s",d);getchar();
if(!strcmp(z.b,d))
char i;
printf("是否要修改密码?(输入y修改,n退出!)");
scanf("%c",&i);
if(i=='y')
printf("请输入修改密码:");
scanf("%s",z.b);
p=fopen("m.txt","w+");
fprintf(p,"%s %s",z.a,z.b);
fclose(p);
printf("修改成功!");
else printf("密码错误!");
else printf("用户名错误");
fclose(p);
参考技术A #include <stdio.h>
#include <string.h>
#define MAX_ACCOUNTS 32
#define MAX_NAME_LEN 32
#define MAX_PWD_LEN 32
#define REGIST 1
#define LOGIN 2
#define MODIFY 3
#define DELETE 4
typedef struct account
int flag;
char name[MAX_NAME_LEN];
char password[MAX_PWD_LEN];
ACCOUNT_T;
ACCOUNT_T g_user[MAX_ACCOUNTS] = 0;
void input(ACCOUNT_T *input)
printf("请输入不超过%d位的用户名\\n", MAX_NAME_LEN-1);
scanf("%s", input->name);
printf("请输入不超过%d位的密码\\n", MAX_NAME_LEN-1);
scanf("%s", input->password);
ACCOUNT_T *find()
int i = 0;
ACCOUNT_T tmp = 0;
input(&tmp);
for (i = 0; i < MAX_ACCOUNTS; i++)
if (1 == g_user[i].flag
&& 0 == strcmp(g_user[i].name, tmp.name)
&& 0 == strcmp(g_user[i].password, tmp.password))
return &g_user[i];
return NULL;
ACCOUNT_T *new()
int i = 0;
ACCOUNT_T *p = NULL;
for (i = 0; i < MAX_ACCOUNTS; i++)
if (0 == g_user[i].flag)
p = &g_user[i];
break;
if (p)
input(p);
p->flag = 1;
printf("注册成功\\n");
else
printf("注册失败 最多%d个用户\\n", MAX_ACCOUNTS);
return p;
ACCOUNT_T *modify()
ACCOUNT_T *p = NULL;
p = find();
if (p)
printf("请输入新的不超过%d位的密码\\n", MAX_NAME_LEN-1);
scanf("%s", p->password);
else
printf("找不到该用户\\n");
return p;
void del()
ACCOUNT_T *p = NULL;
p = find();
if (p)
memset(p, 0, sizeof(ACCOUNT_T));
printf("删除完毕\\n");
else
printf("找不到该用户\\n");
return;
ACCOUNT_T *login()
ACCOUNT_T *p = NULL;
p = find();
if (p)
printf("允许登入\\n");
else
printf("不允许登入\\n");
return p;
int main(int argc, char *argv[])
int action = 0;
while(1)
printf("请输入操作码: %d.注册 %d.登入 %d.修改密码 %d注销\\n"
, REGIST, LOGIN, MODIFY, DELETE);
scanf("%d", &action);
switch(action)
case REGIST:
new();
break;
case LOGIN:
login();
break;
case MODIFY:
modify();
break;
case DELETE:
del();
break;
default:
printf("不支持的操作%d\\n", action);
break;
return 0;
题外话,你真抠,这么多就5分,要不是我太闲了,不会有人帮你写的。
本回答被提问者采纳Android Github和码云等托管平台的凭据,以及添加修改账号密码
Github和码云等托管平台的凭据
开始菜单 -> 控制面板 -> 用户账户和家庭安全 -> 凭据管理器 -> 如下图,可编辑可添加
ps:如果你修改了某个代码托管平台的密码,那么android studio 就不能拉取和上传代码了。需要重新验证,也就是修改凭据
GitHub打不开怎么办?
//找到host文件夹(C:\\Windows\\System32\\drivers\\etc),用记事本打开,添加下面的地址: 192.30.253.112 github.com 192.30.253.119 gist.github.com 151.101.100.133 assets-cdn.github.com 151.101.100.133 raw.githubusercontent.com 151.101.100.133 gist.githubusercontent.com 151.101.100.133 cloud.githubusercontent.com 151.101.100.133 camo.githubusercontent.com 151.101.100.133 avatars0.githubusercontent.com 151.101.100.133 avatars1.githubusercontent.com 151.101.100.133 avatars2.githubusercontent.com 151.101.100.133 avatars3.githubusercontent.com 151.101.100.133 avatars4.githubusercontent.com 151.101.100.133 avatars5.githubusercontent.com 151.101.100.133 avatars6.githubusercontent.com 151.101.100.133 avatars7.githubusercontent.com 151.101.100.133 avatars8.githubusercontent.com
以上是关于C语言用c写一个可以验证账号,密码和修改密码的程序的主要内容,如果未能解决你的问题,请参考以下文章