【发布时间】:2019-04-30 06:00:35
【问题描述】:
我正在制作用户名和密码。在此之前,当我输入 backspace 时,不是擦除密码,而是 backspace 输入了一些东西,我想出了使用 ASCII,但我不知道脚本删除密码。
int a=0, i=0;
char uname[10], c=' ';
char pword[10], code[10];
char user[10]="user";
char pass[10]="pass";
a:
system("cls");
printf("\n\n\t\t\t======================================");
printf("\n\n\t\t\t| STUDENT REPORTING SCORE SYSTEM |");
printf("\n\n\t\t\t======================================");
printf("\n\n\t\t\t=========== LOGIN FIRST ============");
printf("\n\n\n\t\t\t\tENTER USERNAME : ");
scanf("%s", &uname);
printf("\n\n\t\t\t\tENTER PASSWORD : ");
while(i<10)
{
pword[i]=getch();
c=pword[i];
if(c==13) break;
else if(c==8)
//here is the blank
else printf("*");
i++;
}
pword[i]='\0';
i=0;
if(strcmp(uname,"user")==0 && strcmp(pword,"pass")==0)
{
printf("\n\n\n\t\t\tWELCOME TO STUDENT REPORTING SCORE SYSTEM\n\t\t\t\t LOGIN IS SUCCESSFUL");
printf("\n\n\n\t\t\t Press any key to continue...");
getch();
}
else
{
printf("\n\n\n\t\t\t SORRY !!!! LOGIN IS UNSUCESSFUL");
getch();
goto a;
}
我不知道该在//here is the blank 中写什么。所以当我使用a-=2时,它并不想删除*,也不会输入任何内容。
【问题讨论】:
-
递减
i? -
你应该使用函数而不是
goto -
@George 我试过了,但还是一样,无法删除
-
@Peter 但如果我将 goto 更改为函数,它不会影响我的问题