pointer to a structure in a nested structure
- by dpka6
I have a 6 levels of nested structures. I am having problem with last three levels. The program compiles fine but when I run it crashes with Segmentation fault. There is some problem in assignment is what I feel. Kindly point out the error.
typedef struct {
char addr[6];
int32_t rs;
uint16_t ch;
uint8_t ap;
} C;
typedef struct {
C *ap_info;
} B;
typedef struct {
union {
B wi;
} u;
} A;
function1(char addr , int32_t rs, uint16_t ch, uint8_t ap){
A la;
la.u.wi.ap_info->addr[6] = addr;
la.u.wi.ap_info->rs = rs;
la.u.wi.ap_info->ch = ch;
la.u.wi.ap_info->ap = ap;
}