J
jdm
I've got some code similar to the below in which a certain amount of
data is output during each iteration of a for loop.
I'm curious as to whether I need to call setf() and precision() again
every time I open the stream (it's opened for a different file each
time, so I can't just leave it open); or if they'll stay set after the
first time they're called, even if the stream is closed and then
reopened.
std:fstream fout(test_filename.c_str(), ios:ut);
if (!fout)
{
//Handle
}
fout<<"No data to output yet.";
fout.close();
for (current_run = first_run; current_run < no_of_runs; current_run++)
{
//Do some stuff with hillclimbs.
fout.open(output_filenames[current_run].c_str(), ios:ut); //
output_filenames is a vector of std::string
fout.setf(ios_base::fixed, ios_base::floatfield);
fout.precision(8); //Do I REALLY need to call these on EVERY
loop iteration?
for (hc_cf_number_temp = 0; hc_cf_number_temp <= no_of_hillclimbs;
hc_cf_number_temp++)
{
fout<<costs_data[current_run][hc_cf_number_temp];
}
fout.close();
}
Thanks,
James McLaughlin.
data is output during each iteration of a for loop.
I'm curious as to whether I need to call setf() and precision() again
every time I open the stream (it's opened for a different file each
time, so I can't just leave it open); or if they'll stay set after the
first time they're called, even if the stream is closed and then
reopened.
std:fstream fout(test_filename.c_str(), ios:ut);
if (!fout)
{
//Handle
}
fout<<"No data to output yet.";
fout.close();
for (current_run = first_run; current_run < no_of_runs; current_run++)
{
//Do some stuff with hillclimbs.
fout.open(output_filenames[current_run].c_str(), ios:ut); //
output_filenames is a vector of std::string
fout.setf(ios_base::fixed, ios_base::floatfield);
fout.precision(8); //Do I REALLY need to call these on EVERY
loop iteration?
for (hc_cf_number_temp = 0; hc_cf_number_temp <= no_of_hillclimbs;
hc_cf_number_temp++)
{
fout<<costs_data[current_run][hc_cf_number_temp];
}
fout.close();
}
Thanks,
James McLaughlin.