小弟第一次用这个论坛,大哥们帮看看
我最后从 printf("Now,Crack system start!!!"); //程序这里开始有问题了,用穷举法尝试到的密码第一个字母总是显示为中文乱码,哪里出错了?另外太困了,早上还要上课,中午要用程式,再帮我把最后那一段加个统计穷举时间的函数吧,谢谢啦
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include<time.h>
int main(int argc,char *argv[])
{
char pw[100];
char abc[100];
printf("Set a password or select a random password if you press the Enter button:\n");
gets(pw);
srand((int)time(0));
if (pw[0]=='\0')
{
for(int i=0;i<10;i++)
{int m=rand()%94;
pw[i]=m+33;
pw[10]='\0';}
};
printf("Your password is ");
for (int j=0;;j++)
{
if(pw[j]=='\0') break;
printf("%c",pw[j]);
}
printf("!\n\nNow,input your password to login your system:\n");
for(;;)
{
char mn[100];
gets(mn);
if(strcmp(mn,pw)==0)
{
printf("Congratulations on your successful login system!!!\n");
break;
}
else printf("Input error!!!\n");
}
for(;;)
{printf("Now you can press Y or y to reset your password or press N or n to start crack!\n");
char ch=getchar();
if (ch=='Y' || ch=='y')
{
printf("Input your new password:");
scanf("%s",pw);
printf("Your password is ");
puts(pw);
}
else if (ch=='N' || ch=='n') break;
else printf("Input error!!!");
}
printf("Now,Crack system start!!!"); //程序这里开始有问题了
for (int k=0;;k++)
{
int p;
for(int l=33;l<=126;l++)
{
abc[k]=l;
if(strcmp(pw,abc)==0)
printf("Your keyword is ");
puts(abc);
p=0;
break;
}
if (p==0) break;
}
}