I have a problem reading a file using delimeter; read and compare password and username. Currently, my code only allows me one username and one password, each in a separate text file.
I would like my text file to be in this format, and the function will check the text file line by line, and each username and password are separated by a ";"
user;pass user2;pass2 user3;pass3
Here is my current code.
void Auth() { ifstream Passfile("password.txt", ios::in); Passfile>>inpass; ifstream Userfile("username.txt", ios::in); Userfile>>inuser; //system("clear"); cout<<"USERNAME: "; cin>>user; cout<<"PASSWORD: "; cin>>pass; Userfile.close(); Passfile.close(); if(user==inuser&&pass==inpass) { cout<<"\nLogin Success!!\n"; cin.get(); Members(); } else { cout<<"\nLogin Failed!!\n"; main(); } }
source share