My program is having a problem with getline. It seems to skip over random getlines i have in my program. And sometimes outputs will be skipped. For instance, in the following code, it displays the first cout, then skips the getline (meaning it will go right to the if-else with no input), displays the correct or incorrect (always incorrect because the getline didnt work), and then skips the last cout. I have no idea what could be causing this.

cout<<word[randomNum[b]]<<endl;
getline(cin, guess);


if(guess == definition[randomNum[b]])
cout<<"Correct"<<endl;
else
cout<<"Incorrect"<<endl;

cout<<definition[randomNum[b]];



The weird part is, if i do this:

cout<<word[randomNum[b]]<<endl;
getline(cin, guess);
getline(cin, guess);

it will read the input.