int main()
{
int i,j,k;
i=1;j=2;k=3;
int *p =&k;
*(p-1)=0;
printf("%d%d%d",i,j,k);
getch();
}
the output is 1 2 3.
int main()
{
int i,j,k;
i=1;j=2;k=3;
int *p =&k;
*(p-1)=0;
printf("%d%d%d",i,j,k);
getch();
}
the output is 1 2 3.
Your program exhibits undefined behavior, the pointer arithmetics you're doing is invalid.
You can only do pointer arithmetics on pointers that actually point into an array, and the result of the addition or subtraction must still point inside the array (or one past its end, if you don't intend to dereference it).
So anything could happen, the compiler can generate whatever code it feels like for that code.
You are not allowed to refer to p-1
after assigning it &k
this is an invalid pointer for you, and the behavior of using it is undefined.
A run-time error only occurs if your stray pointer hits something that raises that error, such as some protected memory or a location that will later become a divisor in some calculation (0), for example.