How to use FILE correctly?

I don't know very well how to use FILE (fopen, fread, fwrite etc.).
When I use FILE I should use it like this:
I want this: I've got an actor variable (myactor.myvar[0]) with an array of 10. First I want to save the variables in a binary file (../folder/filename) and with an event the game should load the variables and give them the actor.
Can anybody show me a correct code with explanations for the arguments in fwrite / fread?
When I use FILE I should use it like this:
- Code: Select all
FILE *myfile; //like "int myvar" or "char *mychar" I think
myfile = fopen("../folder/filename", "r+b"); // opens "filename" and read that binary file
fread( ? ); // I don't know what to write
fclose(myfile); //close the file
I want this: I've got an actor variable (myactor.myvar[0]) with an array of 10. First I want to save the variables in a binary file (../folder/filename) and with an event the game should load the variables and give them the actor.
Can anybody show me a correct code with explanations for the arguments in fwrite / fread?