Posted By: deianthropus
Accessing properties of structs defined within structs (SOLVED - 07/27/10 06:13
I figured it out: i just need to define the instance of the struct I want to use as a member of the other struct, and use the -> operator to distinguish which object I am extracting which property from...
[original question] When defining one struct as a pointer within another, how does one assign values to the variables and pointers within the child struct? The manual suggests I can use pointers to structs when defining structs.
[original question] When defining one struct as a pointer within another, how does one assign values to the variables and pointers within the child struct? The manual suggests I can use pointers to structs when defining structs.
Code:
typedef struct { var a; var b; var c; } CHILD; typedef struct { struct CHILD* ch_struct; //the manual suggests I can do this } PARENT; PARENT parent_struct { //can I set ch_struct.a here? Or does ch_struct already need to be defined? }