I've to make several experiments of some algorithms. I want to send those results to a .txt file
//....
for (count= 1; count<= 20; count++){
//....
std::cout<<exp<<"Time: "<<duration << " seconds" <<'\n';
ofstream f2;
f2.open("results.txt", ofstream::out);
for(int i=0; i<=20; i++){
f2<<duration<<endl;
}
f2.close();
}
With this code, I only get the same result repeated several times, instead of saving a result per line. What do I need to modify of this code??