/* 编译器 TC */
#include <stdio.h>
#include <dos.h>
void main(void){
union REGS inregs,outregs;
int index;
char password[255];
do{
printf("Enter password:");
index = 0;
do{ inregs.h.ah = 8; /* int 21h 功能 8 键盘输入无回显 */
intdos(&inregs,&outregs);
if(outregs.h.al == '\r')
password[index] = NULL;
else if(outregs.h.al == '\b'){
if(index){
index --;
printf("\b \b");
}
else
printf("\a");
continue;
}
else{
printf("*");
password[index] = outregs.h.al;
}
if(index == 255){
password[index-1] = NULL;
break;
}
if(!password[index])
break;
else
index ++;
}while( 1 );
if(strcmp(password,"jiangnan")){
putchar('\a');
printf("\nInvalid password\n\n");
}
else{
printf("\n\nPassword is ok !\n");
break;
}
}while(1);
system("pause");
}
评论