Because you defined the struct
as consisting of char
arrays, the two strings are the structure and freeing the struct
is sufficient, nor is there a way to free the struct
but keep the arrays. For that case you would want to do something like struct { char *firstName, *lastName; }
, but then you need to allocate memory for the names separately and handle the question of when to free that memory.
Aside: Is there a reason you want to keep the names after the struct
has been freed?