當前位置:首頁 » 編程語言 » 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;
}
}