我编了一个小程序,首先要进行注册和登陆才能使用里面的菜单功能,
但我遇到了一个小问题:
在输入密码的时候,怎样让输入的字符变成"*"号啊,
望高手解答,不胜感激!
[此贴子已经被作者于2004-09-11 14:41:47编辑过]
passwrd(char *p,char *w)
{
char *s,*t;
int key=0,n=0,gd=DETECT,gm=0;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
setcolor(RED);
rectangle(160,230,440,250);
outtextxy(200,235,"welcome to this program!"); getch();
cleardevice();
rectangle(160,230,440,250);
outtextxy(170,235,"you must input Register the code!"); getch();
while(key!=3)
{
cleardevice();
setcolor(RED);
rectangle(160,230,440,250);
outtextxy(170,235,"please input code for my name:");
rectangle(250,300,350,320); gotoxy(33,20);
while(n<12&&(s[n++]=getch())!=13)
if(s[n-1]==8){ if(n==1)n--; else { gotoxy(wherex()-1,20); printf(" "); n--; printf("%c",s[n]); n--; } }
else printf("*");
s[--n]='\0';
cleardevice();
rectangle(160,230,440,250);
outtextxy(170,235,"please input code for my QQ: ");
rectangle(250,300,350,320); gotoxy(33,20);
n=0;
while(n<12&&(t[n++]=getch())!=13)
if(t[n-1]==8){ if(n==1)n--; else { gotoxy(wherex()-1,20); printf(" "); n--; printf("%c",t[n]); n--; } }
else printf("*");
t[--n]='\0';
if(strlen(s)!=10&&strlen(t)!=8){ key++; mywrong(); continue; }
for(n=2;p[n]!='\0';n++){ p[n]=p[n]&n; w[n-2]=w[n-2]|n; }
if(s[0]==p[0]&&s[1]==p[1])for(n=2;s[n]!='\0';n++)if((s[n]&n)!=p[n]){ key++; mywrong(); continue; }
for(n=0;t[n]!='\0';n++)if((t[n]|(n+2))!=w[n]){ key++; mywrong(); continue; }
break;
}
if(key==3)bye();
cleardevice();
rectangle(160,230,440,250);
outtextxy(235,235,"password right");
getch();
closegraph();
}
这个是我的一个程序中的密码函数 你可以看看 具体的程序见
http://bbs.bc-cn.net/bbs/dispbbs.asp?boardID=39&ID=443&star=2&page=1