Strings Question

So in this program I'm writing, I ask for firstName, lastName, and date.
I would like to output data to a file with the filename format of:
firstName_lastName_date.txt

So I basically need to define another string based on other strings while adding underscores.

Is this even possible? It seems like it'd be overly complicated, but I am interested to see if it can be done.

Thanks in advance for any help you can lend.
1
2
string filename = firstName + "_" + lastName + "_" + date + ".txt";
ofstream out( filename.c_str() );



You will need
#include<fstream>
in the header.
I was really overcomplicating it... Thanks!
Topic archived. No new replies allowed.