C:简易控制台版密码验证;
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <windows.h>
int main(int argc, char** argv){
char pwd[21]="";
char ch;
int i, j;
system("cls");
for(i=0;i<3;i++){
printf("Please type password:n");
j=0;
while(j<20&&(ch=getch())!='r'){
pwd[j++]=ch;
putchar('*');
}
pwd[j]='0';
if(strcmp(pwd,"123456")==0){
system("cls");
printf("Welcome!n");
getch();
break;
}else
printf("nPassword Error!n");
}
if(i>=3){
printf("n你到底知不知道密码是啥?!n");
exit(0);
}
return 0;
}