I read this in a book.

I tested the code and found out that it's sizeof integer multiplied by p. Can you some explain the precedence order of this?Code:`apple = sizeof (int) * p;`

thanks alot.

Printable View

- 08-10-2010nimitzhunterprecedence question
I read this in a book.

Code:`apple = sizeof (int) * p;`

thanks alot. - 08-11-2010quzah
What's confusing? All you are doing is multiplying the size of an integer by the value of p. There's no precedence order confusion here. What else could it possibly be? All you are doing is taking two things, multiplying them, and assigning that value some place.

Quzah. - 08-11-2010Bayint Naung
sizeof has higher precedence than multiplication operator.

So the exp is equivalent to

apple = (sizeof(int)) * p;

Guess what will be the value of :

apple = sizeof p * p; // don't forget to init p to some vale

:D - 08-11-2010Elysia
It doesn't matter in what order multiplication is done in. Why the confusion?

- 08-11-2010Bayint Naung
OP is probably thinking: apple = sizeof (int) * p as

apple = sizeof( (int) *p); // say p is pointer to say (char)

which you need to know precedence.

If I'm not wrong, is it from Expert C Programming book?