Ok all you pro's here's another question that's got me thinking and I can't find any answers in my books.
Lets say we have a struct defined below:
Now lets say I got me a pointer (lptr) pointing to any studentPtr, and lets also say that I want to free() said pointer.Code:typedef struct studentType { char *first; char *last; struct studentType *next } student; typedef student *studentPtr;
Now iff I use
Will that also free up the memory that was malloc'ed for those char pointers?Code:free(lptr);
I have always been under the impression that when you use
free(), especailly on a struct, it will free() up everything, included the memory reserved within the struct.
If you're not following, let me know and I'll post the question and my answer (was on an exam) and where I lost points.
Thanx!