code acting a bit strange

Hi,
just doing a simple progamme for my younger brother(a funny news spread).The programme asks for his name,favourite simpsons character and the like but halve way thru the code it starts out putting 2 questions without waiting for input from the user.Cant see what im doin wrong,

works fine down as far as 'your favourite number',then prints the next 2 questions,then waits for user input and then prints out the next 2 questions.Will try and put in cin.ignore at the offending parts.
thanks for quick reply

The cin >> call will leave the trailing newline character in the input stream. Then...

Code:

string Party;
cout<<"what famous peson would u like at your party?"<<endl;
getline(cin,Party);
string hatedPet;
cout<<"what is the pet animal you hate the most?"<<endl;
getline(cin,hatedPet);

The next call for input in the following getline statement sees the newline in the input stream and thinks that the user typed something in and pressed the "Enter" key so you see the question printed to the screen but you can't type in anything for that question. After that first getline eats the newline left over from the cin >> call, the second getline asking you for your "most hated pet animal" will work as intended.

Mixing calls to cin >> and getline can confuse many that aren't aware of the details of what's going on and leave them scratching their heads. You should call cin.ignore() after any cin >> call that comes before a getline statement to eat the trailing newline... so in this case it looks like you only need it once in your sample code.

By themselves, a group of cin >> calls or a group of getline calls all by themselves will work fine because of how they work in dealing with leading/leftover newlines/whitespace in the input stream. With cin >>, leading whitespace (including newlines) is stripped and then any data will get processed. With the getlines however, leading newlines are taken as the user having typed something in so there is a difference in how they work that you need to be aware of.

"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens