Why FILE * does not store the address of an open file

This happens because C uses pass-by-value for function argument passing.

If you want to make changes to a variable passed as an argument to a function from that function itself, you’ll be needing a pointer to that variable to be passed to the function and inside the function, you can modify the value pointed by the pointer and in the caller, it will persist.

Otherwise, to get the value back from the called function, usually we return the value and assign it to the variable in the caller function.

Leave a Comment