struct Student *pStudent;
To dereference individual components (called fields) of a structure, we can do one of the following:
pStudent->name[0] = '\0'; // more common (*pStudent).name[0] = '\0'; // this works, too
The first method is more common. The ->
operator (points-to)
dereference a struct pointer and specifies a field.
The second method works as well. First, (*pStudent)
dereferences
the pointer, so the outcome becomes a student record
(struct Student
). Then, we use .name
to access a
component called name
in the structure.