I'm currently studying C and I have a question in which I have to guess what values are in the memory.
When I say, for example long var1[1243] = {10, 1, 0, -1, -10} and define this vector, the first 5 elements of it are already defined, but the allocated bytes that represent the remaining 1238 elements, what are they set as in memory? More specifically, are they 0? Would saying, in assembly, after defining them, .zero <number of remaining bytes in vector> correct?
By having at least some elements initialized {10} C will initialize all the remaining elements in the array the same as a global variable. Either numeric zero or null pointer depending on type, and in the case of arrays of structs, all members of the struct, recursively.
In C++ an empty initializer also works long var1[1243] = {}, but that is not allowed in C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With