First, let's define real definitions to make this concrete.
struct b { int x; }; struct a_with_b { struct bb; } struct a_with_b_ptr { struct b *bp; }
When you encapsulate a structure, you just need to highlight the external structure (and since the internal structure is not a pointer, you use . To refer to members of the internal structure):
struct a_with_b *a1 = malloc(sizeof(struct a_with_b)); a1->bx = 3;
But when you encapsulate a pointer, you must select each independently and use -> when referring to members of the internal structure:
struct a_with_b_ptr *a2 = malloc(sizeof(struct a_with_b_ptr)); a1->b = malloc(sizeof(struct b)); a1->b->x = 3;
source share