
~~~~~~~~~~~~~~~好好学习~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include<stdio.h>
#include<windows.h>
#include<string.h>
__declspec(dllexport) void demo()
{
#define PASSWORD_SIZE 100
#define PASSWORD "myGOODpassword\n"
int count = 0;
char buff[PASSWORD_SIZE]="";
for(;;)
{
// 提示用户输入密码并且读取他
printf("enter password: ");
fgets(&buff[0],PASSWORD_SIZE,stdin);
// 针对参数值匹配输入的密码
if(strcmp(&buff[0],PASSWORD))
{
// “声诉”密码不匹配
printf("WRONG password\n");
}
else break;
// 鉴定失败计数值+1,并且在密码试输三次后终止程序运行
if(++count > 2) return ;
}
// 程序执行到这里,意味着用户输入的密码是正确的
printf("password ok!\n");
}