Functions, structs and pointers
From Applied Science
Pointers to struct provide a convenient way to access struct's members. The concept of pointers to struct is the same as pointer to any other variable: we first have to declare the variable and the pointer to it, then make the pointer point to that variable's memory address. The advantage of using pointers to structures is that in case we have a function that does something which requires data from a struct we don't have to pass all the struct's values to the function, just a reference, a pointer which can directly access the struct's members.
Errors of logic:
- If the pointer to struct is not pointing to a struct, trying to use it to access a struct's member will cause the program to crash;
- Pointers to struct and structs must match each other's type to avoid errors.