Okay so the following code works as expected EXCEPT for some reason if I put a space when inputting the name e.g. (Mitchell Maygs) the while loop will continuously execute and I don't mean once I mean it will repeatedly output the line
cout << "Invalid type. Please enter either p (permanent) or c (casual)" << endl;
until it crashes. Why does the use of the spacebar cause this and how do I fix it?
When a user types something and then hits enter, cin only reads until the first white space/newline (by default). Therefore, there are extra characters that'll remain in the stream which causes cin to have a bad state. As is the case of your example, that loop continues indefinitely since the stream is never put into a good state again.