How can I use the same variables in two different functions? C++?

How can I use the same variables in two different functions? C++?




Here is an example:



int register_account()

{

string sUsername;

string sPassword;

string question;



cout << "Please enter your new user-name: ";

cin >> sUsername;



cout << "Please enter your new password: ";

cin >> sPassword;



cout << "Creating your account..." << endl;

cout << "Returning to home screen..." << endl;



cout << "Do you want to 'login'?" << endl;

cin >> question;



if(question == "login")

{

login();

}

}



int login()

{

string slUsername;

string slPassword;



cout << "Please enter your user-name: " << endl;

cin >> slUsername;



cout << "Please enter your password: " << endl;

cin slPassword;



if(slUsername == sUsername && slPassword == sPassword)

{

special_message();

}

}





No Answers Posted Yet.