![]() |
getline()'s and loops
I'm building a simple program to translate a sentence typed in into l33t. (I know, it's stupid, but I thought it would be a good programming exercise for me.) I have hit a road block of sorts. I have a loop that contains the main part of the program, and in that loop I have a getline()(string:: I think?) to get typed text into a string object. Well, the program works perfectly until the client wants to run the loop again. On the second time around it seems that the getline() doesn't except the input and skips directly to the part where it asks the user if he/she wants to go through the process again. Here is my code and help would be appreciated. Thanks.
:
|
Re: getline()'s and loops
I'm guessing there's still a newline in the buffer, so
getline is picking it up each time it loops through. You need to read it and discard it.:
getline(cin, eng); |
Re: getline()'s and loops
Thanks, it took some strategic placing, but it did the trick! :)
|
| All times are GMT -5. The time now is 3:45 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC