I am reading lines from a CSV and don't know what size it'll be, so I place read lines into a list of a structure "obs". Then I want to iterate through this list, put it into another list and then modify contents of the original list so that I can print that later. I am, however, not sure if I'm actually modifying the original.
using namespace std;
struct obs{
int date;
int p;
int attr_price;
int q;
double bcode;
double uniq_store_id;
};
int main(){
string line;
ifstream fdata("jumboa_corrected.csv");
obs last_obs;
getline(fdata,line);
int scanned = sscanf(line.c_str(),"%i,%i,%i, %lf, %lf",&last_obs.q,&last_obs.date,&last_obs.p,
&last_obs.bcode,&last_obs.uniq_store_id);
list<obs> this_series(1,last_obs);
obs this_obs;
while(getline(fdata,line)){
++gi;
sscanf(line.c_str(),"%i, %i,%i, %lf, %lf",&this_obs.q,&this_obs.date,&this_obs.p,&this_obs.bcode,&this_obs.uniq_store_id);
this_series.push_front(this_obs);
... stuff that fills in a bunch of this_obs into the list
if(condition to start unloading){
list<obs*> qtr_ser_obs;
for (list<obs>::reverse_iterator it=this_series.rbegin() ; it != this_series.rend(); ++it )
{
qtr_ser_obs.push_front(&*it);
for (list<obs*>::reverse_iterator qtr_obs_it =qtr_ser_obs.rbegin(); qtr_obs_it !=qtr_ser_obs.rend();qtr_obs_it++){
(*qtr_obs_it)->attr_price= computed_attr_price;
}
}
}
In this last line, what am I modifying?
Any help would be greatly appreciated. I guess I'm really not sure what is being placed with the line " qtr_ser_obs.push_front(&*it);
"