Right, so I'm trying to create like a login system and my overall goal is to do it in classes but for the meantime, I won't. So this is my main file:
#include <cstdlib>
#include <iostream>
#include "functions.h"
using namespace std;
void checkDetails(string user, string pass);
string usernames[10];
string passwords[10];
int main(int argc, char *argv[])
{
string user_username;
string user_password;
usernames[1] = 'Phillip';
usernames[2] = 'Phillip';
usernames[3] = 'Phillip';
passwords[1] = 'pass';
passwords[2] = 'pass2';
passwords[3] = 'pass3';
cout << "Please enter your username";
cin >> user_username;
cout << "Please enter your password:";
cin >> user_password;
checkDetails(user_username, user_password);
system("PAUSE");
return 0;
}
void checkDetails(string user, string pass)
{
for(int i=0; (i < 10); i++)
{
if(user == usernames[i])
{
if(pass == passwords[i])
{
cout << "You're in the system";
}else{
cout << "You're not in the system";
}else {
cout << "Your pass was not recognised";
}
}
So, basically the checkDetails is going to check to see if the username and password match. But if they do, it runs another function "getUser" which displays all the users information but how do I do it because it's stored in a array? For example:
getUsers(usernames[i]);
Wouldn't work, would it?
Thanks for any help and advice!