求一个函数可以把输入的密码用星号表示,(返回值为输入的密码),谢谢
答案:3 悬赏:30
解决时间 2021-02-12 12:24
- 提问者网友:泪姬迷茫
- 2021-02-11 21:09
求一个函数可以把输入的密码用星号表示,(返回值为输入的密码),谢谢
最佳答案
- 二级知识专家网友:猖狂的痴情人
- 2021-02-11 21:58
please input password:
****
Wrong!
******
Right!
Press any key to continue
#include
#include
#include
main()
{
int i,flag=1;
char ch,pass[50]={0};
printf("please input password:\n");
fflush(stdin);
while (flag)
{
memset(pass,0,sizeof(pass));
i=0;
do
{
ch=getch();
pass[i++]=ch;
printf("*");
}while (ch!=13);
pass[--i]='\0';
if (strcmp("admin",pass)==0)
{
printf("\nRight!\n");
flag=0;
break;
}else
{
printf("\nWrong!\n");
}
}
}
****
Wrong!
******
Right!
Press any key to continue
#include
#include
#include
main()
{
int i,flag=1;
char ch,pass[50]={0};
printf("please input password:\n");
fflush(stdin);
while (flag)
{
memset(pass,0,sizeof(pass));
i=0;
do
{
ch=getch();
pass[i++]=ch;
printf("*");
}while (ch!=13);
pass[--i]='\0';
if (strcmp("admin",pass)==0)
{
printf("\nRight!\n");
flag=0;
break;
}else
{
printf("\nWrong!\n");
}
}
}
全部回答
- 1楼网友:转身→时光静好
- 2021-02-11 23:02
星号
- 2楼网友:情战辞言
- 2021-02-11 22:05
void mima()
{
char c[100];
int i,j;
printf("请输入密码");
scanf("%s",&c);
i=strlen(c);
for(j=0;j
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯