I know the initial value of an array is 0 when defined as static and undefined otherwise, but I’m not entirely sure if this is the same way when the array is typedef’d. I think so, but I want to confirm it.
Just to make it clear, I mean something like this:
typedef float vector3[3];
int main (int argc, char* argv) {
vector3 vec;
static vector3 vec2;
}
The vec variable would be undefined, wouldn’t it? What about vec2? It should be all 0, right?
Yes, the values in
vecwould be undefined; the values invec2would be all zeroes.The use of a
typedefmakes no difference to the behaviour of the type when variables are defined or declared.