i'm coding a game program for my c class and i need some help.
okay, at the beginning of the game it reads the high scores from a .txt file and prints it to the screen. the standard file is called scores.txt, so it would look kind of like this:
inp = fopen("scores.txt", "r");
fscanf(inp, "%d%d%d%d", &score1, &score2, &score3, &score4);
printf("Best Scores\t%d\t%d\t%d\t%d", score1, score2, score3, score4);
but i am supposed to give the option of changing the score file. I was thinking of doing this with strings, for example:
inp = fopen("string_name.txt", "r");
i tried doing someting like:
char string_name = "scores";
inp = fopen("%s.txt", string_name "r");
and then another function to redefine string_name with whatever filename the user chooses, but it says theirs too many arguments or something.
Is there a way to use strings as the filename in fopen()? or is there another simple way i can achieve this?