Pointer Arithmetic


Above is link of my code
How here value of a changed to 1 ?
what p[1], p[0] point to in non array variables?
Please explain

a is pointing to p array
a points to first index
so if u print a
then value at index 0 of p is printed which is 1

But here p is pointing to a.
NOT a is pointing to p

pointer

by add i mean address of a is 100 ( supposed)
now since p is pointing to the memory location of a
and then u update the value at p[0] which is actually pointing to memory location of a so indirectly the value of a is getting updated

So p[1] does not make sense. right?


in above code i have used typecasting of same code. Now can you please explain output !
How a is incremented by 1?

probably no because, i am not even able to access it using *(p+1)
or assinging it to another pointer
it is giving runtime error if u access p+1

for the updated case code, i request u to go through the below article, its nicely explained
in case the doubt still persists feel free to ask

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.