I am sorry if this was previously addressed. I searched for it and couldn't find it.
Is it possible to create a file with a variable as its name. For example let's say the database has the name of a person entered. Can a output file be put out with all the persons information but their name being the name of the output file?
Either the user inputs the file extension manually, our you can do filename + ".txt" or whatever before you try to open the file if it's always the same extension. Also, you ought not to use cin>> for strings; using getline() instead.
To add the file extension on the expression itself, you can use std::ofstream myfile((filename+extension).c_str());
Or you can append the extension before opening the file. filename.append(extension); //or filename+=extension;