B
bochengnever
( ) and -> are left to right in the same order . eg:
struct foo
{
int a ;
void * p;
}
main()
{
struct foo* A= malloc(sizeof(struct foo));
(char*)A->p;
}
(char*)A->p I think should be a compiler error,because (char*)A evalute
first ,now A come be a pointer to char ,so A do not have a field of p .
But it compiled successfully.So A->p first evaluted,
it seem to conflict to the associativity of () and -> .
thank you
struct foo
{
int a ;
void * p;
}
main()
{
struct foo* A= malloc(sizeof(struct foo));
(char*)A->p;
}
(char*)A->p I think should be a compiler error,because (char*)A evalute
first ,now A come be a pointer to char ,so A do not have a field of p .
But it compiled successfully.So A->p first evaluted,
it seem to conflict to the associativity of () and -> .
thank you