// Principle: how to get a computed number to a file name #include #include #include #include using namespace std; int main() { const string str = "res_"; for (unsigned i=1;i<5;i++){ ofstream out(str+to_string(cos(i))); out.close(); } } /* opened files res_0.540302 res_-0.416147 res_-0.989992 res_-0.653644 */