This dereferences an uninitialized pointer, resulting in UB:
*p = i;
You probably want this instead:
p = &i;
solved pointer behaviors in c++
This dereferences an uninitialized pointer, resulting in UB:
*p = i;
You probably want this instead:
p = &i;
solved pointer behaviors in c++