I have written code which allows the user to input a password and user name and then the user will input it again and compare the 2. I want to make this into a function and call it from main() but i am unsure how to do this. Any help would be appreciated. Everything works in the code, but i am unable to figure out how to make it a function that can be called. thanks.
/Verifies that the passed in char string conforms to User Name requirements
//return true if the char string conforms, false if it doesn't
bool verifyUserNameFormat(const string& userName);
//Verifies that the passed in char string conforms to Password requirements
//return true if the char string conforms, false if it doesn't
bool verifyPasswordFormat(const string& password);
//Prompts for input to create a new user
//returns true if user account is successfully created
//userName and password will contain the new username and password on successful creation
//returns false if user account creation fails
//userName and password will be empty if account creation fails
bool newUserPrompt(string& userName, string& password);
//Verify userName and password are correct
//returns true if correct
//returns false if incorrect
bool loginVerify(const string& userName, const string& password);
//Prompt for user login
bool loginPrompt();
I recommend using STL strings instead of char arrays.
newUserPrompt() will call verifyUserNameFormat() and verifyPasswordFormt().
loginPrompt will call loginVerify().