#include <string.h>
main()
{
char a[15],i=3
do{
printf("Password:")
gets(a)
if(strcmp(a,"hello")==0) break//这里请连到你的密码文件或者是连接到数据库验证,这里是 hello
}while(--i)
if(i==0) printf("Input errer 3 num.System close!\n")
else
{
//这里写入你密码正确要执行的代码
}
}
用strcmp函数比较两个字符串,你上图一个生成的字符串,另一个输入的字符串,把这两个传递到函数里,函数返回0就说明两个字符串相等,输入正确,反之输入错误。(头文件导入string.h)。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)