I have c++ program in which I am running the same function many times but each time for a different value of a parameter. For each value of the parameter I want to output the result of the function to file whose name contains the value of the parameter. How to do this? Here is an example of what I want to do.
for(parameter = 10;parameter<=100;parameter*=10){
ofstream file("file"<<parameter<<".txt", ios::out);
function();
file<<result;
file.close();
}
You could do this with
ostringstream: