18,773
社区成员
发帖
与我相关
我的任务
分享
void safe()
{
char s[20]= {0},password2[20]="123456";
int k,i;
int len = strlen(password2);
char ch;
printf("pls input passwd\n");
for(k=1;k<4;k++)
{
i=0;
printf("di %d ci input passwd\n",k);
while((ch=fgetc(stdin))!='\n')
{
s[i]=ch;
printf("*");
i++;
}
printf("\n");
// if(fgets(s, 20, stdin) != NULL)
{
if(strncmp(s,password2,len)==0)
break;
printf("s = %s p = %s\n", s, password2);
memset(s, '\0', 20);
}
}
if(k<=3)
printf("passwd Ok!\n");
else
{
printf("out of range\n");
exit(-1);
}
}
void safe()
{
char s[20]= {0},password2[20]="123456";
int k;
int len = strlen(password2);
printf("pls input passwd\n");
for(k=1;k<4;k++)
{
//i=0;
printf("di %d ci input passwd\n",k);
#if 0
while((ch=fgetc(stdin))!='\0')
{
s[i]=ch;
printf("*");
i++;
}
#endif
if(fgets(s, 20, stdin) != NULL)
{
if(strncmp(s,password2,len)==0)
break;
printf("s = %s p = %s\n", s, password2);
memset(s, '\0', 20);
}
}
if(k<=3)
printf("passwd Ok!\n");
else
{
printf("out of range\n");
exit(-1);
}
}