3 ms·
Even if we simplify it this way, arrays are still different because they cannot be assigned to and their decayed pointer can never be NULL (they always have a b
by bluetomcat 10y ago
Even if we simplify it this way, arrays are still different because they cannot be assigned to and their decayed pointer can never be NULL (they always have a backing storage provided by the compiler):
int arr[5];
int *ptr;
// "arr" has a fixed backing storage of sizeof(int) * 5 bytes
// "ptr" may point to anything or be NULL, depending on control flow
- jandrese 10y agoBest to check for NULL anyway though, because anything can happen once you let it decay to a pointer. Never assigning them is a good idea though, maybe it's best to think of them as constant pointers? But that's more confusing terminology for a C programmer, so maybe not. People get really wrapped around the axle when differentiating a constant pointer from a pointer to a constant.