C: Passing files as parameters

I am having trouble passing a FILE pointer as a parameter into multiple functions.

I want to open the file in main, then pass it down into a function, which will write some things into it, then from that function pass it into another function. I can pass it from main to the first function no problem, but when I try to pass it to the second function it has a Segmentation fault.

You're passing score in line 56 in your call to sscanf, but you should pass it's address. So add an ampersand:

int r = sscanf(input, "%s%s%s%d", command, fName, lName, &score);

After that, the error is gone and test.txt reads like this:

testbc123testcd23cd23

In C, arguments to functions are ALWAYS call by value. So if sscanf should write to the variable, passing the variable doesn't help. You actually have to pass it's address, so sscanf can write to it. That the other three variables (command, fName and lName) don't need an ampersand is because in C, you also cannot pass arrays. If you try to pass an array, indeed you're passing a pointer to it's first element. So the function prototypes