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.
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.
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.
Hope is the first step on the road to disappointment.
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
Last edited by Bayint Naung; 08-10-2010 at 11:37 PM.
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?
Last edited by Bayint Naung; 08-10-2010 at 11:59 PM.