@malojinaik
Do you mean that you tried to add two pointer values together (like
pab below)?
- int a;
-
int b;
-
int *pa = &a; // The value of pa is the address of a.
-
int *pb = &b; // The value of pb is the address of b.
-
-
int *pab = pa + pb; // What does this mean?
-
int c = *pab; // !!! Danger !!!
-
I suppose you can add two pointer values together, but to what end? What do you think that is going to accomplish?
Suppose the address of
a is 0x0200 (that's the value of
pa) and the address of
b is 0x0204 (that's the value of
pb). In that case, the value of
pab is 0x0404. What is stored there? What happens when I try to assign a value to
c? Either address
pab is outside the bounds of my program and we crash with an access error; or worse, some arbitrary garbage value is pulled from somewhere in my program and written to
c.