C struct array default values -
this question has answer here:
i have struct:
typedef struct { gpio_typedef* gpio_reg; uint16_t gpio_pin; uint16_t status; } pintype; then if declare array:
pintype array[10]; the pintype elements in array initialized default values?
for example, if write this:
printf("%d", array[1].status); should see 0 output? or initial value depends on content of memory before declared array?
this answer depends on scope of variable.
- if
arrayglobal, auto-initialized. - if
arraystatic, elements auto-initialized0. - if
arrayofautomaticstorage, won't initialized automatically.
Comments
Post a Comment