|
-
December 13th, 2006, 08:07 PM
#1
getline help
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|