i got a strange things with vector.push_back ... i wrote inside a loop
while(size = getSectionSize(inputFile) ){
data->at(k).resize(size*3) ;
sizes.push_back(size) ;
cout << "sizes at k = "<< k << " = " << sizes.at(k) << endl;
double val;
int j=0;
while(getline(inputFile,row) && j < size){
istringstream elem(row);
for(int i=0; i < 3; i++)
//elem >> data->at(k).at(j).at(i);
elem >> val ;
data->at(k).at(j).push_back(val);
elem >> tmp ; // 4th columns to skip
j++;
}
but i got
terminate called after throwing an instance of 'std::out_of_range'
... instead if i write inside a loop
for(int i=0; i<size; i++) // resize vector !
data->at(k).at(i).resize(3) ;
and then reads the the data from file with push_back the program goes fine but if i try to write out the data i got a lot of 0 0 0 (this should be related to the fact that with resize the vector increase 2*size ... and not just size)
so I have to use the orrible :
elem >> data->at(k).at(j).at(i);
In this way everythings goes fine ! but i would understand why push_back doesn't works without a previously resize!!