I am trying to write data files out of a particle physics simulation that I have built, but I am having trouble trying to make the file name work like I want it to. The problem is the amount of data I have to write, and the number of files I have to write. I want to make a function that I can call, and have write the datafiles, but it needs to put the names for them together itself. Here is an example.
If the problem with strings is that the file opening function only takes c-strings, this is easily solved. You can just do myString.c_str() to return the c-string equivalent of your string, which will be accepted by the file opening function.
// necessary includes and stuff
string fileName = "myFile.txt";
oFile.open(fileName); //This gives an error in some compilers, as it will not impicitly convert string to c-string
oFile.open(fileName.c_str()); //This will work, as it explicitly does the necessary conversion