0

Can you help me with this C++ code?

What is the problem in this code? I enter correct username and password but it said it is not correct! _______________________________________ #include <iostream> #include <conio. h> using namespace std; int main() { int pass; char username[100]; char password[100]; cout << " Welcome to TH Server\n--------------------------------------------------------------------------------"; cout << " Enter your username : "; cin >> username; cout << " Enter your password : "; cin >> password; if ( username == "taha"){ if ( password == "91765430911"){ pass == 1; } } else{ pass == 0; } if ( pass == 1) { cout << "--------------------------------------------------------------------------------"; cout << " Welcome to your panel Taha."; } else { cout << "--------------------------------------------------------------------------------"; cout << " Username or password is not correct!" ; } getch(); return 0; } ________________________________________ Sorry for its writing😅

11th Jan 2019, 9:23 AM
Taha Lahooti
Taha Lahooti - avatar
7 Answers
+ 4
You should use the assignment operator = when assigning a value to 'pass' inside the if-else statement. Currently you are using the comparison operator ==, which does not assign the value to 'pass', therefore 'pass' ends up uninitialized.
11th Jan 2019, 9:36 AM
Shadow
Shadow - avatar
+ 4
Taha Lahooti Your code, though seem simple, is not really readable... Use code playground for share (create new code, write your code, save it and share the url of that code here) your code so its more simple help you and try to format it better
11th Jan 2019, 9:30 AM
KrOW
KrOW - avatar
+ 1
Thanks
11th Jan 2019, 9:37 AM
Taha Lahooti
Taha Lahooti - avatar
+ 1
Please post a link to the code, my brain instantly turned off after see it .-. (No offence)
12th Jan 2019, 3:20 AM
Pirate_Programmer
Pirate_Programmer - avatar
+ 1
Remove <conio. h>
16th Feb 2019, 7:09 PM
¿°°ANONYMOUS™~
¿°°ANONYMOUS™~ - avatar
0
😅
12th Jan 2019, 7:38 AM
Taha Lahooti
Taha Lahooti - avatar
0
Thanks
11th Apr 2019, 6:29 PM
Taha Lahooti
Taha Lahooti - avatar