0

Im trying to do a username and password login panel in my program and when i input the userid and password it shows the else output.In this case there are two different id and password which is when ID is "danisl"the password is "adapt2" while when the id is "arifrl" the password is "adapt1". the codes are

char userid[10],password[10];
while(y==1)
{
 cout<<"username:";
 cin.get(userid,9);
 cout<<"password:";
 cin.get(password,9);
 if(userid=="arifrl")
 {
    if(password=="adapt1")
    { 
     y=0;
    }
    else 
    {
        cout<<"incorrect password";
    }
 }
 else if(userid=="danisl")
 {
        if(password=="adapt2")
        {
        y=0;
        }
        else
        {
            cout<<"incorrect password";
        }
 }
 else 
 {
   cout<<"incorrect ID";
 }
 }
  • 1
    Tip: In C++ use `std::string` whenever you can. – tadman Apr 08 '20 at 01:22
  • @Thomas The problem with the string comparison is explained in the first linked duplicate. The problem is precisely that OP is *not* using `std::string` to which you linked, but C style `char` arrays. – walnut Apr 08 '20 at 01:32

0 Answers0