I can get a file to write to a specific file name using the following code.
simple enough.Code:ofstream outfile("name.dat"); outfile << username << endl; outfile << age << endl; outfile.close();
But instead of it writing to a file "name.dat"
I would like it to write to a file that is equivalent to the username.
I've tried a few thigns like the following
But apparantly that doesn't follow the fstream rules. I've experimented with a whole bunch of other failed options apparantly I'm going about this the wrong way. Can someone give me some insight that might point me in the right direction.Code:ofstream outfile(username + ".dat"); outfile << username << endl; outfile << age << endl; outfile.close();