Levi Campbell wrote:
I have a function that as one of its arguments is a variable for a file
name, how would I use the variable to fill in the file name when
calling fopen?
As you would use a string as an argument to any other function taking a
string as an argument. For example,
#include <stdio.h>
int main(void)
{
FILE *fp;
char foobar[] = "random.filename.txt";
if (!(fp = fopen(foobar,"r")))
{
fprintf(stderr,"Oh crap! I couldn't open \"%s\" for input.\n",
foobar);
}
else fclose(fp);
return 0;
}