2007
10-18

你正好弄相反了,, 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;
}


帮忙》有 1 条评论

  1. 5iluo 说:

    你正好弄相反了,, 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;
    }

留下一个回复