Hello JLaw21,
I did some rearranging on the program.
Added
#include <string>
and changed the variables to
std::string username{ "Andy" }, password{ "asdf" }, id, pass;
and it worked just fine. The only problem I see is the "username" and "password" can only store one name and password. A "std::map" may be worth considering.
Defining the variables as "string"s I had to change the prototype and function definition for create so that the program would compile.
In both "menu" functions the while loop works better as a do/while loop. To do this you need to include the "cout" statement for the menu and remove the prompt and "cin >>" after the switch for it to work.
Tip:
Try not to use single letter variables in your prototypes and function definitions. It makes it hard to follow when reading the code.
As an example:
1 2 3 4 5 6 7
|
void create(std::string &username, std::string &password)
{
std::cout << "Please create a username: ";
std::cin >> username;
std::cout << "Please create a password: ";
std::cin >> password;
}
|
The variables "username" and "password" become local variables to the function. That is why you can use the same names. The fact that they are being passed by reference makes no difference except that the will change the calling variables.
You can use all lower case letters for your variable names, but the "cameCase" method is more often used. So "username" would be "userName". It does help with readability, but not necessary. I would suggest staying with whatever way you choose to write your variable names. Being consistent is better than mixing.
So far I have just worked with the menus. In "menu" I would suggest making "case 1" a function call and not doing the work there.
Now I look at the other functions and see what happens.
Hope that helps,
Andy