#include
#include
int main (void)
{
int a[] = {1,2,3,4,5};
int b[] = {0,0,0,0,0};
int *p = b;
for (int i =0; i <
You are getting undefined behavior. At the end of the first loop p points to "one past the end" of b. Without resetting it, you then dereference it and continue to increment it, both of which cause undefined behavior.
It may be that on your implementation the array a is stored immediately after array b and that p has started to point into array a. This would be one possible "undefined" bahaviour.