I need to create random unique file names, I plan to use a value returned from a time function
to capture a value to use to name new files. My main problem is in opening a new output file stream
using a variable.
string filename ;
timer = time(NULL);
filename = reinterpret_cast(timer) ;
filename.append( ".dat" );
ofstream outf ( filename , ios::out);
I know there are a number of reasons this code won't work, it's just to give you
an idea of what I want to do. The line I'm actually trying to solve is:
"ofstream outf (filename, ios::out);"
In all the examples I've found the 'filename' is a constant text value surrounded by
double quote marks. I would like to be able to use a variable there so it can be set to
the time value returned when the file was created.
Is this even possible? If not could you suggest an alternative?