I'm basically trying to get the user's name (and I want them to be able to use spaces, which is why I have to use getline) and then the name of their fictional kingdom. But when I run this code, it skips ahead of itself. It asks for the name, but then it skips and asks for the kingdom name before even allowing the user to input their name. I've tried cin.ignore() but that doesn't work. Anybody have any suggestions?
string playerName = "nyd"; //declaring string playerName
string kingdomName = "nyd"; //declaring string countryName
int monarchAge; //declaring monarch age variable.
cout << " Welcome, your majesty! What is your name?\n";
getline(cin,playerName);
cout << " And what is the name of your grand kingdom, " << playerName << "?\n";
getline(cin,kingdomName);
cin.ignore();
cout << " And finally, how old are you, Lord " << playerName << " of " << kingdomName << "?\n";
cin >> monarchAge;