I am trying to google my issue, but I think I don't know the right terminology
I am making a "login with username and password" toy program
I have some objects in a class, and I want to compare "username" to "password"
I am trying to write the code so that when it runs it will identify when a username matches a password, not just one username and password combination...but from all of them at once
I am brand new to C++ so please be gentle!!! I just don't know the terms to enter into a search
I am making a "login with username and password" toy program
I have some objects in a class, and I want to compare "username" to "password"
I am trying to write the code so that when it runs it will identify when a username matches a password, not just one username and password combination...but from all of them at once
I am brand new to C++ so please be gentle!!! I just don't know the terms to enter into a search
Code:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
class User
{
public:
string username;
string password;
string key;
string pass;
};
int main ()
{
string key;
string pass;
User user1;
user1.username = "Mark";
user1.password = "Jambalaya";
User user2;
user2.username = "Grace";
user2.password = "Gumbo";
User user3;
user3.username = "Addie";
user3.password = "Shrimp";
User user4;
user4.username = "Natalie";
user4.password = "Spices";
User user5;
user5.username = "Hillary";
user5.password = "Sausage";
std::cout << ("Enter your username:\n") << endl;
std::cin >> key;
std::cout << ("Now, enter your password:\n") << endl;
std::cin >> pass;
if (key == User.username && pass == User.password) //THIS IS WHERE I CANT FIGURE OUT THE RIGHT SYNTAX
{
std::cout << ("Access granted!\n") << endl;
}
else
std::cout << ("Access denied!\n") << endl;
}