I’m trying to read from a file, but the only thing I get on working is using getline().
The problem is that reading a whole line doesnt to the job for me.
My input file looks like this:
abc 10 20
bbb 10 30
ddd 40 20
when the first word in each line should be saved as a string, and both number afterwards as ints.
The delimiter between the “words” in each line can be either a SPACE or a TAB.
So is the only solution is reading char by char? Or is there another solution?
Supposedly you want something like this:
This doesn’t make sure that the values are all on one line, however. If you want to arrange for this you probably want to read a line using
std::getline()and then split this line up as above using anstd::istringstream.