string to path conversion

I am coding a mathematical simulation in c++, and each time I run the simulation, I want the output data (from an ofstream) to save in a unique location. I am using the __TIME__ and __DATE__ macros to generate the unique file names, in order to prevent overwriting previous data. I define the ofstream, like this for example:

1
2
ofstream dataOut;
  dataOut.open("randomFileName.txt");


but wish the argument of the open() call to be defined by

1
2
3
string DATEmacro=(string)(__DATE__);
  string TIMEmacro=(string)(__TIME__);         
  string filepath=DATEmacro+TIMEmacro;


However, using the syntax
dataOut.open(filepath.txt)
does not work correctly.

I'm no expert in C++, and hopefully there is a relatively simple solution, as I'm sure there is.

Thanks in advance!
of course it does not work. as you may know, the parameter of filepath for open is of string type, as a result you should write it like this:
dataOut.open(filepath+".path")
Hope it will help.
Topic archived. No new replies allowed.