#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
char str[20],pw[]="123456";
int i=0,k=0;
while(1)
{
printf("请输入密码:");
while(gets(str),strlen(str)>8);
if(strcmp(str,pw)==0)
break;
else
printf("密码错误!");
i++;
if(i>=3)
exit(0);
}
printf("密码输入成功");
putchar('\n');
}
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
char str[20],pw[]="123456";
int i=0,k=0;
while(1)
{
printf("请输入密码:");
while(gets(str),strlen(str)>8);
if(strcmp(str,pw)==0)
break;
else
printf("密码错误!");
i++;
if(i>=3)
exit(0);
}
printf("密码输入成功");
putchar('\n');
}