你正好弄相反了,, strcmp(userpassword,password),,,,如果两个参数相等的话,返回0
所以,,
int password()
{
const char password[]=”Hello”;
char userpassword[20];
cout<<”Enter your password:”;
cin>>userpassword;
if(strcmp(userpassword,password) != 0)
{
cout<<”you are illegitimate user!”<<endl;
exit(1);
}
else
cout<<”OK!”<<endl;
return 1;
}
int main(void)
{
password();
return 0;
}
>> 本文固定链接: http://www.vcgood.com/archives/1875
你正好弄相反了,, strcmp(userpassword,password),,,,如果两个参数相等的话,返回0
所以,,
int password()
{
const char password[]=”Hello”;
char userpassword[20];
cout<<”Enter your password:”;
cin>>userpassword;
if(strcmp(userpassword,password) != 0)
{
cout<<”you are illegitimate user!”<<endl;
exit(1);
}
else
cout<<”OK!”<<endl;
return 1;
}
int main(void)
{
password();
return 0;
}