I am trying to do an assignment where I created an input file to be read then outputted with information read in to be sorted into three columns. Problem is the first two lines are word lines followed by the 3rd line being a double variable which goes on in the pattern for 15 lines. My problem with the coding is how do i get the getline to work after the variable because i have played with it to figure that part out but it doesnt want to work at all with reading the 4th line at all after the first variable is read. I am not asking for the assingment to be completed but a nudge in the right direction would be greatly appreciated. I have the code up to this:
When you use >> to read the double value, it doesn't remove the newline character on the end, so the next time you try to read with getline() it hits the newline immediately and gives you the empty string. You can ignore the rest of the line after the double value with something like: cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
which just ignores all characters up to and including the newline.