I am currently in the process of making my first text-based RPG ( based on C++). I want to have users make an account before they start playing the RPG. Is there anyway to make a code that can store user-name's and passwords.
string user , pass;
map<string , string> mp;
// register :
// ... get username and password into "user" and "pass"
mp[user]=pass;
// login :
// ... get username and password into "user" and "pass"
if ( (!mp.find(user)==mp.end()) || (mp[user]!=pass) ) cout<<"LOGIN FAILED"; else cout<<"LOGIN SUCCESS";
system("pause");
For each value of string user (who has registered), mp[user] would return the password of that username. Just check if the login password is it.
Remember to use #include<map> at the beginning of your program, (and #include<iostream> and usingnamespace std; if you use my code)