#include <stdio.h>
int main(void){
char pw[10],pw1[10];
printf("Please enter your password,no less than 3 and no more than 8 characters:\n");
gets(pw);
while(strlen(pw)<3||strlen(pw)>8)
{
if(strlen(pw)<3)
{
printf("Sorry, too few, try again:\n");
gets(pw);
}
if(strlen(pw)>8)
{
printf("Sorry,too many, try again:\n");
gets(pw);
}
}
printf("Please enter your password again:\n");
gets(pw1);
while(strcmp(pw,pw1) )
{
printf("Sorry, your password not match!\n Re-enter again:\n");
gets(pw1);
}
printf("Your password is %s.\n",pw);
return 0;
} |