getline(); not working

http://pastebin.com/m4f94e320

On line 38 and 88 my getline() command is not working or being ignored for some reason. I had to put in cin.get(); above them to get them work, but I was wondering if you guys had any idea why.

Also if you see any areas where I could improve upon would be appreciated.
because you've use cin >> before getline()
i'm no expert but base on what i know, when you have use cin to get an integer input a newline character is left in the stream which is use by the getline function as a guide that it is the end of the input..

adding this piece of code before using getline() might solve the problem
cin.ignore(256, '\n');
because you've use cin >> before getline()
i'm no expert but base on what i know, when you have use cin to get an integer input a newline character is left in the stream which is use by the getline function as a guide that it is the end of the input..

adding this piece of code before using getline() might solve the problem
cin.ignore(256, '\n');

It will.
really? that's great!
Just to sum up:

>> _ takes in the next data (char, string or numerical) in the input stream till the whitespace or the new line character

.get() _ one characer a time and this character can be also a whitespace or a new line character

.getline() _ the whole line till and including new line character


And also
getline() command is not working or being ignored for some reason
it is working and not being ignored, it just takes in whatever comes next till and including the new line character, but in case of your program only new line character.

more info _ http://www.cplusplus.com/reference/iostream/istream/
Topic archived. No new replies allowed.