If I had an array of structures (like a database say) and I entered in 5 people. How could I make a program that prints out a file for each of the people without actually coding the filename into the program.

For example there's a guy named Joe in my database. I want to print out all of the info in his struct file (name and age for example). What I'm trying to do is make a program that runs through the array and for each person make a file called name.txt which contains a name and an age. So for Joe's file, it would be joe.txt. But I don't know how to do this without coding file=fopen("joe.txt", "w") into the program.

This is a bit verbose and I don't know if this is very clear but I've tried to be. So yes, any help would be greatly appreciated. Thanks.