M
Mahendra
I have the following structs -
15 typedef struct pSimple {
16 char *key;
17 char *val;
18 } pSimple, *pSimple_ptr;
19
20 typedef struct pComplex {
21 char *name;
22 int value;
23 } pComplex, *pComplex_ptr;
24
25 typedef struct pNode {
26 char *nodeId;
27 struct pSimple *semStats;
28 struct pComplex *sysStats;
29 } pNode, *pNode_ptr;
Now somewhere in my main() i do -
pNode data;
and then call generate_data(&data); where i want to initialize the
"data". Now the question i have is -
1. When i do- pNode data, does it allocate struct pNode ? If yes, it is
in stack ? If not what exactly does it does ? Can i just use &data to
initialize the struct pNode or do i have to allocate heap memory for it ?
Thanks
Mahendra
15 typedef struct pSimple {
16 char *key;
17 char *val;
18 } pSimple, *pSimple_ptr;
19
20 typedef struct pComplex {
21 char *name;
22 int value;
23 } pComplex, *pComplex_ptr;
24
25 typedef struct pNode {
26 char *nodeId;
27 struct pSimple *semStats;
28 struct pComplex *sysStats;
29 } pNode, *pNode_ptr;
Now somewhere in my main() i do -
pNode data;
and then call generate_data(&data); where i want to initialize the
"data". Now the question i have is -
1. When i do- pNode data, does it allocate struct pNode ? If yes, it is
in stack ? If not what exactly does it does ? Can i just use &data to
initialize the struct pNode or do i have to allocate heap memory for it ?
Thanks
Mahendra