简体   繁体   中英

Structure double Referencing error in C

I am puzzled by the errors i get for referencing structure members.

I have structure like this,

typedef struct
{

    Int32      *pInAddr[2];
    Int32      a;

}JobInfo_t;

typedef struct
{

    ULUnitJobInfo_t               JobInfo[MAX_JOBS_PER_CORE];
}DispatchInfo_t;

DispatchInfo_t *ptr,temp;
ptr=&temp;
Fun(ptr) //Fun is some function

I pass it into the function Fun.c as

Fun ( *ptr)
{

i get error when initializing

    ptr->JobInfo[0]->pInAddr[0]=0;
    ptr->JobInfo[0]->a=0;
}

error: expression must have pointer type

I dont know then how to access array of pointer within the structure pointer or accessing simple data (a) from structure pointer?

Another question: If I try to access Int32 temp= ptr->JobInfo[0].pInAddr[0]; It gives me message

"Expression must have modifiable l value"

JobInfo is an array of JobInfo_t, not an array of pointers.

Try that :

ptr->JobInfo[0].pInAddr[0]=0; ptr->JobInfo[0].a=0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM