[color=Green]/** Address p is pointed to x **/[/color] : p = &x;
[color=Green]/** First, find out what value is on the right side of the expression:
++x - first, increment x and THEN USE it in expression x++ - first, USE x in expression and THEN increment it
1. Incremented x will mean 7 2. 7 must be added to a location pointed by p 3. But, location p points to x, which is now 7 4. 7+7 = 14 (x will be now 14) **/[/color] : *p += ++x; [/code]
Comments
: int x = 6, *p;
[color=Green]/**
Address p is pointed to x
**/[/color]
: p = &x;
[color=Green]/**
First, find out what value is on the right side of
the expression:
++x - first, increment x and THEN USE it in expression
x++ - first, USE x in expression and THEN increment it
1. Incremented x will mean 7
2. 7 must be added to a location pointed by p
3. But, location p points to x, which is now 7
4. 7+7 = 14 (x will be now 14)
**/[/color]
: *p += ++x;
[/code]
what is the meaning of *p?
(int *p) = p is a pointer to an integer. Rite?
Then, now the answer is 7, your explained is well, i can understand.
But, how become 7+7=14?
: *p += ++x; means what?
Sorry! I'm a stupid...
*p is the value of pointer p
++x means x=x+1
*p+=++x equivalent to *p=*p+++x or *p=*p+x+1
_______________________________
???????? ?????? ??????| employment / freelance jobs