密码设置程序,
#include "stdio.h"
#include "conio.h"
#define MIN 6
#define MAX 12
void main()
{int loop;
char password1[13],password2[13];
for(;1;)
{
clrscr();
printf("\n please input a password(6~12characters):");
for(loop=0;loop<MAX;loop++)
{password1[loop]=getch();
printf("*");
if(password1[loop]=='\x0d')
{if(loop<MIN)
{printf("\n\n the length of the password is less then 6,press any key to repeat...");
getch();
printf("\n\n please input a password again(6~12characters):");
loop=-1;
}
else
{password1[loop]='\0';
break;
}
}
if(loop==MAX -1)
password1[loop]='\0';
}
printf("\n\n please input 2 password again(6~12characters):");
for(loop=0;loop<MAX;loop++)
{password2[loop]=getch();
printf("*");
if(password2[loop]='\x0d')
{password2[loop]='\0';
break;
}
if(loop==MAX -1)
password2[loop]='\0';
}
if(strcmp(password1,password2) ==0)
{printf("\n\n the password is accepted.");
break;
}
else
{printf("\n\n the second password is not the same with the first,press any key to repeat...");
getch();
}
}
}
[解决办法]
楼主什么问题
[解决办法]
for(loop=0;loop<MAX;loop++)
{password1[loop]=getch();//用getchar()吧
[解决办法]
其实还是不明白楼主想问什么