#include <stdio.h>

#include <stdlib.h>

#include <string.h>

/*string.h是一个和字符串处理相关的头文件

,里面有很多字符串处理的函数,

如果你写程序时要用到里面提供的函数的话,

就应该加。一般来说,只要有字符串处理,最好都加上。

*/

int main()

{

char *passwd = "123456";

char input[10];

int i = 0;

for (i = 0; i < 3; i++)

{

printf("请输入密码:>");

scanf("%s", input);

if (strcmp(passwd, input) == 0)

{

break;

}

else

{

printf("密码输入错误\n");

}

}


if (i == 3)

{

printf("三次密码错误,退出系统\n");

exit(0);

}

else

{

printf("登录成功\n");

}

system("pause");

return 0;

}