![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Call me Chuck
|
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.
C++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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); cin.get(); |
|
|
|
|
|
#3 |
|
Call me Chuck
|
Re: getline()'s and loops
Thanks, it took some strategic placing, but it did the trick!
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|