Set up Login



My question is once the user set up and account bye doing option 2 Then I want the user to have login so how do run programm so it then can retrieve information that user just used to register and the is able to login to my Game





#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>


using namespace std;

int Login;
string password2;





std::string getStringOfMinLength(const std::string& prompt, unsigned minLength)
{





std::cout << prompt << '\n' << "(min length = " << minLength << ")\n" ;

std::string str ;
while ( std::cin >> str && str.length() < minLength )
std::cout << "Not long enough! (min length = " << minLength << ")\n" ;

return str;
}

int UserSetup()

{












std::string userName = getStringOfMinLength("Please enter a user ID", 6) ;
repeat2:
std::string password1 = getStringOfMinLength("Please enter a password", 7) ;


cout << "Please RENTER your password\n";
cin >> password2;

if (password1 != password2)
{
cout << "You have ReEnter your password incorrectly \n";
goto repeat2;
}

if (password1 == password2)
{

cout << "You Now registered with treasure Island\n";
cout << " User name: " << userName << " Password: " << password1 << '\n';
}
}

int Welcome()



{
cout << "Welcome to Adam's Quiz Game\n";
cout << "Login Enter 1 " "Create New Account Enter 2 \n" "Press 3 to Quit\n";

cin >> Login;

if (Login ==2)
{
UserSetup();
}

if (Login ==1)
{








string userName;
string password1;


cout << "Please enter use name\n";
cin >> userName;
cout << "Pleser enter password\n";
cin >> password1;


ifstream ifs("file path");
std::string str;
while(ifs.good())
{
getline(ifs, str);
//do whatever you want to with str;
cout << "You are now logded on to treasure Island\n"
}



}

}




My question is once the user set up and account bye doing option 2 Then I want the user to have login so how do run programm so it then can retrieve information that user just used to register and the is able to login to my Game




int main()

{

Welcome();
Welcome();



system("PAUSE");
return 0;


}
Last edited on
I think you would get help if it wasn't for how hard it is to read your code. You need to put it in code tags and make sure in each tag it's only code.
Topic archived. No new replies allowed.