A. 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;
}
艾達的小刀
是否可以解決您的問題?
B. c語言實訓,有個學生系統怎麼優化,怎麼改
1.主要功能:
(1)能按學期、按班級完成對學生成績的錄入、修改
(2)能按班級統計學生的成績,求學生的總分及平均分,並能根據學生的平均成績進行排序
(3)能查詢學生成績,不及格科目及學生名單
(4)能按班級輸出學生的成績單
(5)將參考模板的程序調試運行通過,並補充完整,實現完整的學生成績管理系統的所有功能(即要將函數聲明部分給出的所有函數全部實現)。 對模板中的程序進行改進、優化,使之更合理、清晰。
(6)添加一個學生成績排序子模塊,可將某文件中的學生信息按成績用選擇法排序,將排序結果寫入文件,並屏幕上列印出來。
(7)添加用戶管理模塊。實現對使用管理系統的用戶的用戶名、密碼的管理,以便用戶登錄模塊進行校驗和許可權判斷。只有教師能夠使用用戶管理模塊的功能。該模塊有以下5個子功能:
1)創建用戶信息文件。
2)增加新用戶。
3)刪除用戶
4)修改用戶
5)瀏覽所有用戶信息
C. 求C語言編寫的用戶登錄程序
#include<stdio.h>
#include<string.h>
main()
{
charname[]="admin",pass[]="888";
charpname[15]={0},ppass[15]={0};
printf("pleaseinputname:");
scanf("%s",pname);
printf("pleaseinputpassword:");
scanf("%s",ppass);
if(strcmp(name,pname)!=0||strcmp(pass,ppass)!=0)
{
printf("nameorpasswordwrong! ");
}else
{
printf("welcome! ");
//你自己要進入的函數
}
}
D. 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中無法編譯或執行的問題。
E. 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;
(5)c語言實慣用戶登錄擴展閱讀:
#include後面有兩種方式,<>;和""前者先在標准庫中查找,查找不到在path中查找。後者為文件路徑,若直接是文件名則在項目根目錄下查找。
引用方法:#include<stdio.h>
注意事項:在TC2.0中,允許不引用此頭文件而直接調用其中的函數,但這種做法是不標準的。也不建議這樣做。以避免出現在其他IDE中無法編譯或執行的問題。
F. 用C語言編程實現用戶登錄問題急需!!!!!!
需要ID和密碼匹配就行了吧?
注冊時讓用戶輸入ID,將其存儲到一個文件中(如data.in),緊接著輸入密碼,存到ID之後;
再次登錄時,用戶輸入ID,判斷ID長度,在文件的每一行搜索同一長度的字元看是否匹配,如果匹配,判斷密碼是否一致即可;
如果還有疑問就補充提問吧,希望回答對你有幫助!
G. 用C語言編的用戶登錄系統
輸入密碼時顯示*的效果可以用下面這個程序得到:#include<stdio.h>
main(){
int i=0;
char password[50];
printf("Input Password:");
while((password[i++]=getch())!=13)putchar('*'); //主代碼
password[i]='\0';
printf("\n\npassword is :%s\n",password);
}
H. 如何用C語言編程實現用戶登錄
C語言的話,一般用戶信息存儲在結構體鏈表裡
你輸入用戶名回車以後,需要遍歷鏈表,使用strcmp()函數逐一對比鏈表裡是否存儲了你輸入的用戶名。不存在輸出「無此用戶」,存在繼續輸入密碼,將密碼與此結點的密碼信息對比,處理方式同用戶名;
至少三次輸入錯誤,可設一個整形變數index = 0,每錯誤一次執行index++,當if(index==3)成立時,輸出相應信息,並執行exit(1);
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;
}
艾達的小刀