
1个回答
展开全部
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main(){
char pw[20];
char ch;
char pw_saved[]="MyPassWd"; // 正确的口令存放在此
int i=0;
cout << "Enter pass\n";
ch = _getch();
while( (ch & 0xff) != 13)
{
if ( (ch & 0xff) == 8) { cout << ch << ' ' << ch; i--;} else { cout << '*'; pw[i]=ch; i++; }
ch = _getch();
}
pw[i]='\0';
if ( strncmp(pw_saved,pw,strlen(pw_saved))==0)
{
cout << "\nAccess granted !\n";
}else{
cout << "\nAccess aborted...\n";
}
}
#include <string>
#include <conio.h>
using namespace std;
int main(){
char pw[20];
char ch;
char pw_saved[]="MyPassWd"; // 正确的口令存放在此
int i=0;
cout << "Enter pass\n";
ch = _getch();
while( (ch & 0xff) != 13)
{
if ( (ch & 0xff) == 8) { cout << ch << ' ' << ch; i--;} else { cout << '*'; pw[i]=ch; i++; }
ch = _getch();
}
pw[i]='\0';
if ( strncmp(pw_saved,pw,strlen(pw_saved))==0)
{
cout << "\nAccess granted !\n";
}else{
cout << "\nAccess aborted...\n";
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询