samedi 5 décembre 2020

two variables are the same but using == does not work

string IP = DownloadString("https://wtfismyip.com/text"); 
string user = "xxxxxx"; 

cout << IP;
cout << user;

if (IP == user)
{
    goto Authorized; 
}
else
{
    cout << "You are not authorized to use this program. Exitting in 5 seconds.";
    Sleep(1000);
    cout << "\rYou are not authorized to use this program. Exitting in 4 seconds.";
    Sleep(1000);
    cout << "\rYou are not authorized to use this program. Exitting in 3 seconds.";    
    Sleep(1000);                                                                       
    cout << "\rYou are not authorized to use this program. Exitting in 2 seconds.";
    Sleep(1000);
    cout << "\rYou are not authorized to use this program. Exitting in 1 second. ";
    Sleep(1000);
    return 0;
}

Hello everybody! i started learning c++ very recently and have encountered a wierd issue.

My issue is that even though the variables "IP" and "user" are the same, it executes the else statement. I know they are the same as they output the same text to the console. "user" is supposed to be my ip which i have obviously blurred here. Hope someone can help me with this. Thank you!

Aucun commentaire:

Enregistrer un commentaire