If I have two arrays likes this:
short** x;
short** y = functionThatReturnsAnArray();
In this situation sizeof(x) == sizeof(y).
Both are 4, I believe that this is because the outer array is simply an array of pointers and therefore doesn’t actually have any RAM allocated to it.
How can I find out that x has not been assigned a value?
Thanks,
Joe
From a comment in your original post, what you mean is whether you can tell if a value has been assigned to a variable. We call that initialization. When a value hasn’t been stored to a variable it’s uninitialized, and that’s bad, because you never know what might be in there, and no, you cannot check whether it has been initialized, so initialize it when you declare it.
sizeof(x) == sizeof(y)because they’re declared as the same type (short**); their contents don’t matter (sizeofis actually determined by the compiler, so it often can’t know what’s in it).If you want to know whether the memory areas that each point to are zero, you’ll need to do it manually (and you need to know how long each array is):