Hello friends,
I'm looking for an short example to read a text file and get lines splitting in 3 vectors. I don't know how I'll do this ...
E.G:
100 NAME1 30
150 NAME2 40
200 NAME3 50
->
vectorId[0] = 100
vectorName[0] = NAME1
vectorAge[0] = 30
Can you help me?
Cheers,
Sads
...
std::string token;
std::istringstream issLine(lineId);
...
if ( myfile.is_open() )
{
while ( ! myfile.eof() )
{
getline(issLine,token, ' ');
if(lineAni.size() > 0)
{
// ERROR IS HERE
substLineId = token;
vectorId.push_back(substLineId);
substLineName = token;
vectorName.push_back(substLineName);
substLineAge = token;
vectorAge.push_back(substLineAge);
}
}
}
...