Reputation: 21
I am unable to access member of a structure
The code is as follows :
int main()
{
typedef struct tempA
{
int a;
}tempa;
typedef struct tempB
{
tempa **tA;
}tempb;
tempb.(*tA)->a =5;
printf("\n Value of a : %d",tempb.(*tA)->a);
}
I tried to access it using tempb.(*tA)->a;
but I am getting syntax error:
error: expected identifier before ‘(’ token
What is the correct syntax to access int a
?
Thanks in advance
Upvotes: 0
Views: 188
Reputation: 55009
The right syntax is (*tempb.tA)->a
. You want to dereference tempb.tA
to get a pointer to a tempA
, then dereference that pointer to access the a
member.
Upvotes: 7