該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
/*--------實現密碼的隱式輸入-----------------*/
inputpw(char?*password,int?len)?/*len為密碼長度*/
{
int?i=0;?/*密碼數組索引值,同時也表示記錄已顯示*的數目*/
char?ch;
fflush(stdin);?/*清洗流,以防妨礙密碼正確輸入*/
for?(ch?=?getch();ch!=13;ch?=?getch()?)?/*若輸入回車則結束密碼輸入*/
{
if?(i>=len)?continue;?/*如果已到達len指定的長度*/
if?(?ch?==?8?)?/*若按了退格鍵*/
{
if?(?i?>?0?)?/*如果已顯示星數不為0*/
{
printf("\b");
password[--i]='\0';?/*password[i-1]的值改為'\0',?已顯示星數減一,數組索引值減一*/
}
putchar(0);?/*顯示空字符*/
printf("\b");
continue?;
}
if(?ch<32?||?ch>127?)?continue;?/*密碼只能為ASCII碼值為32-127的字符*/
printf("*");?/*上述情況都不是則顯示一個星*/
password[i++]=ch;?/*將ch賦給password[i],已顯示星數加一,數組索引值加一*/
}
password[i]?=?'\0';?/*設置結尾的空字符*/
}
/*--------------管理員登錄驗證,返回登錄狀態------------------------*/
int?login(int?x)?/*x傳入第幾次登錄*/
{
char?pws[15],admin[]={"dfghjfgfdg"};?/*密碼設定,未加密*/
clrscr();
if(x?==?2)
printf("Input?the?password?please:");
else
printf("The?password?you?input?is?ERROR!please?input?again:");
inputpw(pws,15);
printf("\nSystem?is?checking?your?status,please?wait...");
sleep(2);
if(strcmp(pws,admin)==0){
return?TRUE;}
else
return?FALSE;
}