G
Gary Wessle
Hi
I have a map<string, double> m_temperatures which gets updated
often.
I need to save the data to files corresponding to each string each
time the map is updated, I am expecting about 80 files in total.
how do I go about it?, do I set a vector<ofstream*> cities; something
like
map<string, double> m_temperatures;
vector<ofstream*> files
/* first create ofstreams and leave them open for appending */
for( map<string, double>::iterataor i = m_temperatures.begin();
i != m_temperatures.end(), i++ ){
ofstream* ofs( i->first.c_str(), ios::app );
files.push_back( ofs );
}
void updating( map<string,double> mp ){
loop through the map and increment a counter, use this counter to
index the vector<ofstream*> which can then be de-refrenced and
values from the map appended to the file.
}
but that is fragile because the order of the map is no guaranty to
correspond to the order of the streams in the vector.
any better ideas.
thanks
I have a map<string, double> m_temperatures which gets updated
often.
I need to save the data to files corresponding to each string each
time the map is updated, I am expecting about 80 files in total.
how do I go about it?, do I set a vector<ofstream*> cities; something
like
map<string, double> m_temperatures;
vector<ofstream*> files
/* first create ofstreams and leave them open for appending */
for( map<string, double>::iterataor i = m_temperatures.begin();
i != m_temperatures.end(), i++ ){
ofstream* ofs( i->first.c_str(), ios::app );
files.push_back( ofs );
}
void updating( map<string,double> mp ){
loop through the map and increment a counter, use this counter to
index the vector<ofstream*> which can then be de-refrenced and
values from the map appended to the file.
}
but that is fragile because the order of the map is no guaranty to
correspond to the order of the streams in the vector.
any better ideas.
thanks