Sure, there's no problem with reassigning the pointer to point somewhere else, with p = &x;

The real problem with your code is that at *p = 10, your pointer is UNINITIALISED. That means the code is broken.

int *p;
int old, new;
p = &old;
*p = 10;
p = &new;
*p = 20;
Remember, before you do *p = something;, you need a p = somewhere; statement before it, otherwise you've no idea what's happened.