I can't figure out a problem I'm having. The input file looks like this:
and I'm trying to use getline() to pick out just the name from each line, and then use ignore() to discard the rest of the line, but my output file ends up looking like this:
Here is the code:
I also tried the same thing creating a dummy variable:
using namespace std;
//I get tellg()=-1 here???
//I thought the get pointer would be 6 here
//so I'm trying to discard the rest of the
//char's on the first line up to an including
//the '\n' to set up for reading the next line
and doing this:
but I got the same output. I thought with this statement:
getline() was supposed to stop reading from the stream after 5 char's or until a '\n' (the default delimiter) was encountered, and therefore I needed to do something to remove the rest of the char's from the line, but it's not working the way I exepected.