pointer to a structure in a nested structure

Posted by dpka6 on Stack Overflow See other posts from Stack Overflow or by dpka6
Published on 2012-08-30T02:23:49Z Indexed on 2012/08/30 3:38 UTC
Read the original article Hit count: 221

Filed under:
|
|

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;

}

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers