How do we acces a member of a pointer structure which is also inside a structure? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do we acces a member of a pointer structure which is also inside a structure?

Its like this structure { *pointerStructure { member; } } https://code.sololearn.com/cwBj0pQkgdyV/?ref=app

4th Mar 2020, 9:24 AM
CASOY
CASOY - avatar
2 Answers
+ 2
Your parentMem is not pointing to an actual 'child' when it's initialized, you have to allocate some memory for it first like: mother.parentMem = (struct child*)malloc( sizeof( struct child ) ); And include stdlib.h
4th Mar 2020, 9:42 AM
Dennis
Dennis - avatar
+ 1
Dennis you really helped me, thanks a lot.
4th Mar 2020, 10:47 AM
CASOY
CASOY - avatar