So I've read somewhere that in case we have a pointer p, and some values i and j defined one after another, then those values on stack will be one after another however that for me at least does not seem to be the case.
int i = 10;
int j = 20;
int *p = &i;
p++;
(*p) = 30;
std::cout << i << " " << j << " " << (*p) << "\n" ;
Instead it will print these values 10 20 30
If I commented the (*p) = 30; instead inside *p will be an empty address.
I thought that the ++ operator in this case will change my reference from i to j and the (*p) will change the value of j, but that isn't the case apparently .
So I was wondering what did they mean ?