I wrote a program which asks the user for certain input. The information that the users input are put into a couple of output files. The data in the output files get combined in various ways and a new output file is created.
Because the program is going to be used for multiple users, it would be
helpful if the output file could have a different name for each user. What I
was hoping was that each user could enter their username. Then their output
file would be their username.txt. As far as I understand, there is no way to
include a variable name in the fopen command. If there were, the filename
that needs to be included in the fopen command, could simply be their
username + .txt.
The only way that I can think of handling this, is by including the whole
body of the program in multiple if statements, with the if statement being
contingent on the particular user name. If the username is ______, do the
whole program with the output file being XYZ. If the username is ________,
do the whole program with the output file being XYZ1 etc. etc.
Please advise. Many thanks!