I\'m having trouble understanding how some pointers work. I always thought that when you created a pointer variable (p), you couldn\'t deference and assign (*p = value) unle
I always thought that when you created a pointer variable (p), you couldn't deference and assign (*p = value) unless you either malloc'd space for it (p = malloc(x)), or set it to the address of another variable (*p = &a)
For practical purposes you thought right. Better keep thinkig that.
If you do what in in your example the behavior of the program is undefined. What means anything can happen, including a misleading "works" feeling. But it is nothing but recipe for disaster.