当前位置:首页 » 编程语言 » c语言编写用户名
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言编写用户名

发布时间: 2022-04-28 05:51:52

Ⅰ 用c语言程序编写用户名密码 程序

#include<stdio.h>
#include<string.h>
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++;
}
}
}

Ⅱ C语言编写用户登录程序

艾达的小刀
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

/*随机码产生函数*/
void RandomCode (char Rcode[])
{
int i;
srand ((unsigned int)time(NULL));
for (i = 0; i < 3; ++i)
Rcode[i] = rand()%10 + '0';
Rcode[i] = '\0';
}
/*登陆函数,判断信息是否匹配,若匹配返回1,否则返回0*/
int LandedApp (char *password[], char Rcode[])
{
char name[10] = {0};
char pword[10] = {0};
char rcode[4] = {0};

printf ("用户名 : ");
gets (name);
printf ("密码 : ");
gets (pword);
printf ("随机码 : ");
gets (rcode);

if (strcmp (name, password[0]) != 0 || strcmp (pword, password[1]) != 0 || strcmp (rcode, Rcode) != 0)
return 0;
else
return 1;
}

int main ()
{
char * password[2] = {"admin", "admin123"}; //用户名和密码
char rc[4] = {0}; //随机码
int count = 3; //可输入次数

puts ("请输入用户名,密码和随机码:");
while (count)
{
RandomCode (rc);
printf ("随机码 : %s\n", rc);
if (LandedApp(password, rc) != 0)
break;
--count;
if (count != 0)
puts ("错误的用户名或密码或随机码,请重新输入: ");
}
if (count != 0)
puts ("\n成功登陆!");
else
puts ("\n登录失败 !");

return 0;
}
艾达的小刀

Ⅲ c语言编写程序,模拟用户注册和登录的过程,实现用户的注册和登录

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char username[20];
char password[20];
char s1[20],s2[20];
int n=0;
printf("--------------------\n 1 注册 \n 2 登录 \n 0 退出 \n--------------------\n 请选择(0-2)\n");
scanf("%d",&n);
while(n==1){
char usernametmp[20];//tmp作为临时保存单位
char passwordtmp[20];
printf("请输入用户名:");
scanf("%s",usernametmp);
strcpy(username,usernametmp);
printf("请输入密码:");
scanf("%s",passwordtmp);
strcpy(password,passwordtmp);
printf("注册成功!\n");
break;
}
while(n==2)
{
printf("输入用户名:");
fflush(stdin);//清空输入缓冲区
gets(s1);
printf("输入密码:");
fflush(stdin);
gets(s2);
if((strcmp(s1,username)==0)&&(strcmp(s2,password)==0)){
printf("登陆成功\n");}
else{
printf("用户名或密码错误!登录失败!\n");}
}
return 0;
}

Ⅳ c语言编写用户登录程序

代码如下:

#include<stdio.h>

#pragma warning(disable:4996)

#include<string.h>

int main()

{

int i = 0;

char password[10] = { 0 };

printf("请输入密码:");

while (i < 3)

{

scanf("%s", password);

printf(" ");

if (strcmp(password, "972816") == 0)

{

printf("登录成功 ");

break;

}

else

{

i++;

if (i != 3)

printf("再输入一次");

}

}

if (i == 3)

printf("密码错误三次退出登录界面 ");

system("pause");

return 0;

(4)c语言编写用户名扩展阅读:

#include后面有两种方式,<>;和""前者先在标准库中查找,查找不到在path中查找。后者为文件路径,若直接是文件名则在项目根目录下查找。

引用方法:#include<stdio.h>

注意事项:在TC2.0中,允许不引用此头文件而直接调用其中的函数,但这种做法是不标准的。也不建议这样做。以避免出现在其他IDE中无法编译或执行的问题。

Ⅳ C语言编写程序,用户名为:used,密码为123

#include<stdio.h>
void main()
{int a;
printf("用户名:used\n请输入密码\n");
scanf("%3d",&a);
if (a==123) printf("欢迎使用\n");
else printf("你输入错误\n");

}

Ⅵ C语言编写一个用户登陆的程序

代码如下:

#include<stdio.h>

#pragma warning(disable:4996)

#include<string.h>

int main()

{

int i = 0;

char password[10] = { 0 };

printf("请输入密码:");

while (i < 3)

{

scanf("%s", password);

printf(" ");

if (strcmp(password, "972816") == 0)

{

printf("登录成功 ");

break;

}

else

{

i++;

if (i != 3)

printf("再输入一次");

}

}

if (i == 3)

printf("密码错误三次退出登录界面 ");

system("pause");

return 0;

(6)c语言编写用户名扩展阅读:

#include后面有两种方式,<>;和""前者先在标准库中查找,查找不到在path中查找。后者为文件路径,若直接是文件名则在项目根目录下查找。

引用方法:#include<stdio.h>

注意事项:在TC2.0中,允许不引用此头文件而直接调用其中的函数,但这种做法是不标准的。也不建议这样做。以避免出现在其他IDE中无法编译或执行的问题。

Ⅶ 怎么用c语言写一个创建用户名和密码并且能修改密码的程序

#include <stdio.h>//我自己做的,你拿去用吧!
#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);

}

}

Ⅷ 怎么用c语言写一个创建用户名和密码并且能

#include
//我自己做的,你拿去用吧!
#include

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);
}
}

Ⅸ 如何用C语言编程实现用户登录

C语言的话,一般用户信息存储在结构体链表里
你输入用户名回车以后,需要遍历链表,使用strcmp()函数逐一对比链表里是否存储了你输入的用户名。不存在输出“无此用户”,存在继续输入密码,将密码与此结点的密码信息对比,处理方式同用户名;
至少三次输入错误,可设一个整形变量index = 0,每错误一次执行index++,当if(index==3)成立时,输出相应信息,并执行exit(1);

Ⅹ 在c语言中如何实现1、 编程实现用户登录问题,如果用户名和密码都输入正确,则提示“欢迎登陆!”,假定用

#include<stdio.h>
void main()
{
char name;
int code;
bool b=true;
while(b)
{
printf("\n请输入用户名:");
scanf("%s",&name);
printf("\n请输入密码:");
scanf("%d",&code);
if(name=='h'&&code==0)
{
printf("欢迎光临\n");
b=false;
}
else{
printf("重新登录\n");
}
}
}

希望对你有所帮助,不明白hi我。。