I was wondering if it's possible to dynamically pass through a string into fopen().
E.g.
String s = Depends-on-user-input.txt
And then is there a way to do
Fopen(s, "r");
I've tried to use this method but it keep getting an error.
it's unclear what you're trying to do. It's certainly possible to have multiple files open at the same time. You just have to have multiple file pointers:
FILE * f1 = fopen("onefile.txt", "r"); FILE * f2 = fopen("anotherfile.txt", "r");
It's that easy.
However, this sounds a lot like pset4 - recover. In this case, you will want to open one file for input, and then will open and close output files, one after another. This is done in a similar way.
If you're trying to do something else, you need to edit the question and give more context. If you have code that isn't working, please post it so we can see it and debug it.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)