1

I have this:

uint8_t buf[X][Y];

I would like to initialize all elements to 0. Will this do the trick:

uint8_t buf[X][Y] = { 0 };

? i.e. will it initialize all X*Y elements to 0?

clami219
  • 2,858
  • 1
  • 29
  • 43
Bogdan Alexandru
  • 5,274
  • 6
  • 33
  • 54

1 Answers1

2

Yes. If you have an initializer ({ ... }), all elements not explicitly initialized will be initialized to zero.

Edit: Removed part that is not correct when using C.

Timbo
  • 26,506
  • 10
  • 48
  • 71