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

c语言登录账号程序

发布时间: 2022-11-18 19:05:57

c语言编写,自定义一个函数,要求如下功能:判断系统的登录账号密码是否正确,并输出登录结果

是三种不同的函数验证登陆吧,check1、check2、check3三类函数分别如下:

void check1()输入输出功能全部在函数完成;

void check2(name,pass)输入在main中传入函数进行判断输出;

int check3(name,pass)输入输出均在main函数完成,函数只做判断返回结果。

#include "stdafx.h"

#include <iostream>

#include <string>

void check1()

{

char name[10], pass[10];

printf("请输入账号和密码: ");

scanf_s("%s%s", name, 10, pass, 10);

if (!strcmp(name,"admin")&&!strcmp(pass,"123"))

printf("账号密码正确! ");

else

printf("账号或密码错误! ");

}

void check2(char *n, char *p)

{

if (!strcmp(n, "admin") && !strcmp(p, "123"))

printf("账号密码正确! ");

else

printf("账号或密码错误! ");

}

int check3(char *n, char *p)

{

if (!strcmp(n, "admin") && !strcmp(p, "123"))

return 1;

else

return 2;

}

int main()

{

char name[10], pass[10];

check1();

printf("请输入账号和密码: ");

scanf_s("%s%s", name, 10, pass, 10);

check2(name, pass);

printf("请输入账号和密码: ");

scanf_s("%s%s", name, 10, pass, 10);

if(check3(name,pass)==1)

printf("账号密码正确! ");

if(check3(name,pass)==2)

printf("账号或密码错误! ");


system("pause");

return 0;

}

㈡ 用c语言模拟银行账号密码登录,那个大神可以指导一下

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>

intchcode(){
charpw[50],ch;
char*syspw="abc";//原始密码
inti,m=0;
printf("请输入密码:");
while(m<3){
i=0;
while((ch=_getch())!=' '){
if(ch==''&&i>0){
printf("");
--i;
}
elseif(ch!=''){
pw[i++]=ch;
printf("*");
}
}
pw[i]='';
printf(" ");
if(strcmp(pw,syspw)!=0){
printf("密码错误,请重新输入! ");
m++;
}
else{
printf("密码正确! ");
system("pause");
return1;
}
}
printf("连续3次输入错误,退出! ");
system("pause");
return0;
}

intmain(){
intlogin=chcode();
if(login)printf("登录成功! ");
elseprintf("登录失败! ");
return0;
}

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

㈣ 在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我。。

㈤ c语言qq自动登录程序如何做

如果是其他的程序登陆,或许可以用用调用打开指定位置的程序,比如c的system(),然后输入start程序路径,然后就是获取窗口句柄,以及编辑框等空间,获取发送信息登陆,但是现在的qq版本的那些空间已经不能获取那些空间的id了,是画出来的,我以前试着要获取qq聊天信息框中的内容,但是不能获取里面的句柄
试试上面的方法,应该是不可以了,那就只有用获取窗口的位置,然后模拟鼠标键盘的操作来搞定了,至于输入账号,就用剪切板粘贴,上面所说的这些都是有api函数可以实现的,这是原理,具体的网络吧

㈥ c语言,字符串密码登录程序

这样修改,是否符合原来的题意?

㈦ C语言编程:实现用户的注册和登录

模拟用户注册和登陆可以用文件来保存用户名和密码。注册就是向文件里写,用if判断两次密码是否一致。连续三次,可以有一个变量,每次输入加一,变量大于三就提示登陆不成功。用户名不对,那你就把你输入的用户名和文件里的用户名是否一致。

㈧ 编一个注册登陆的程序 C语言的

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

bool search(char id[], char pass[]) {
FILE *fp;
char tid[10], tpass[10];
fp = fopen("c:\\data", "r");
while (!feof(fp)) {
fscanf(fp, "%s%s", tid, tpass);
if (strcmp(tid, id)==0 && strcmp(tpass, pass)==0) {
fclose(fp);
return true;
}
}
fclose(fp);
return false;
}

bool login() {
char id[10], pass[10];
printf("Login\nPress the id: ");
scanf("%s", id);
printf("Press the password: ");
// 可以自行将password处理成*号, 如果不会可以发信给我
scanf("%s", pass);
printf("-----------------------");
if (search(id, pass))
return true;
else
return false;
}

void _add(char id[], char pass[]) {
FILE *fp;
fp=fopen("c:\\data", "a");
// 在写入文件时可以按一定的排序方式插入,可减少以后Login时的search时间
fprintf(fp, "%s %s\n", id, pass);
fclose(fp);
}

void regis() {
char id[10], pass[10], tpass[10];
printf("Register\nPress the id: ");
scanf("%s", id);
while (true) {
printf("Press the password: ");
scanf("%s", pass);
printf("Press the password again: ");
scanf("%s", tpass);
if (strcmp(pass, tpass) != 0)
printf("The passwords you pressed are not the same!\n");
else
break;
}
_add(id, pass);
printf("-----------------------Register successfully!\n");
}

void init() {
FILE *fp;
if ((fp=fopen("c:\\data", "r")) == NULL) { // 注意,一定要有个名叫data(没有扩展名)的合法文件在C盘根目录
printf("---------File is not exist\n");
system("pause");
exit(0);
}
else
fclose(fp);
}

int main(void){
int command;
init(); // 检查data文件在不在
while (true) {
printf("-----------------------(Login: 1 Register: 2 Exit: 3)\n");
scanf("%d", &command);
printf("-----------------------\n");
// 这里可以编写command的检测语句
if (command == 3)
break;
else if (command == 1) {
if (!login())
printf("ID is not exist or password is wrong!\n");
else
printf("Login successfully!\n");
}
else
regis();
}
return 0;
}
搞定了。。。我是用成功了的。。。如果有问题就发信给我。。。。

㈨ 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<string.h>
voidignoreCase(char*str)
{
for(inti=0;i<strlen(str);++i)
{
if(str[i]>='A'&&str[i]<='Z')
str[i]+=32;
}
}