First you should know, how much memory is allocated when you define and allocate memory in below case.
typedef struct person{
char firstName[100], surName[51]
} PERSON;
PERSON *testPerson = (PERSON*) malloc(sizeof(PERSON));
1) The sizeof(PERSON) now returns 151 bytes (Doesn't include padding)
2) The memory of 151 bytes is allocated in heap.
3) To free, call free(testPerson).
but If you declare your structure as
typedef struct person{
char *firstName, *surName;
} PERSON;
PERSON *testPerson = (PERSON*) malloc(sizeof(PERSON));
then
1) The sizeof(PERSON) now returns 8 bytes (Doesn't include padding)
2) Need to allocate memory for firstName and surName by calling malloc() or calloc(). like
testPerson->firstName = (char *)malloc(100);
3) To free, first free the members in the struct than free the struct. i.e, free(testPerson->firstName); free(testPerson->surName); free(testPerson);