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 array global, auto-initialized.
  • if array static, elements auto-initialized 0.
  • if array of automatic storage, won't initialized automatically.

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -