Questions are based on the following code :
struct t
{
int * arr;
};
int main()
{
struct t *a = malloc(5*sizeof(struct t));
a[2].arr = malloc(sizeof(int));//line 1
a[2].arr[1] = 3; //line 2
}
- In line 2 I'm accessing the array
arrusing the.(dot) operator and not the->operator. Why does this work? - When i rewrite line 2 as
(a+2)->arr[1] = 3this works. But if I write it as(a+2)->(*(arr+1)) = 3I get a message asexpected identifier before '(' token. Why is this happening?