0

I have an input file something like this(with 1 space between things):

   name             year       game/place
 Big John           1975     game1 2 game2 3
 Jacob Rafael Ben   1975     game1 2 game2 3 game4 1
 ....

I try to read this into a struct like this:

struct Contestant{
    string name;
    int year;
};

Here is the other struct for the games:

struct Result{
    string raceName;
    int place;
};

This is what i do in the next() func:

void next(){
    string line;
    getline(_f, line);
    _end = _f.fail();
    if(!_end){
        istringstream is(line);
        is >> _cur.name >> _cur.year;
        Result tmp;
        while (is >> tmp.raceName >> tmp.place){
            if (tmp.place == 1){
                counter++;
            }
        }
    }
}

All i want here is to read the whole name with spaces into _cur.name

 Contestant _cur;
GetHelp
  • 11
  • 2

0 Answers0