I'm trying to make a login system with usernames, passwords, and individual permissions as a little project while I learn c ++. After the username and password are validated, how do I clear the console of previous information?
It works now, but no matter what it always prints out invalid password. And the program stops working.
So I have a few questions:
1. Is there a way to print out what is making it stop working?
2. How can I create a dynamic array that allows an admin , through the admin menu and a method, to add values into the password and username arrays?
#include<vector>
#include<iostream>
#include<string>
usingnamespace std;
int main()
{
vector<string>passwordlist;
vector<string>usernamelist;
string info;
do
{
cout<<"Add a username then password.\n";
cout<<"Enter user name: ";
cin>>info;
usernamelist.push_back(info);
cout<<"Enter password: ";
cin>>info;
passwordlist.push_back(info);
cout<<"Showing user names and passwords entered...\n";
//do not use sizeof use size method for vectors or size()/length() for string object
for(int i=0; i<usernamelist.size() && i < passwordlist.size();i++)
{
cout<<"User Name: "<<usernamelist[i];
cout<<"\nPassword: "<<passwordlist[i]<<"\n";
}
cout<<"\nContinue entering new usernames and passwords?";
cin>>info;
}while(info=="yes");
}
I plan on creating a GUI for this program. I'm also going to add different permission levels for users. Should I create different files for the methods and just have one main file? Ifyes, please link me to some useful resources that you may have.
Thanks
EDIT: I'm assuming I can use erase() along with a search function I will have to create in order to delete elements?
Also, would it be possible to use Python & C++ to save data to a file?
Like creating a folder and within that folder every username has his own .txt file?
Within that txt file, it lists all of the users information... user, pass, privileges etc.