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,958
  • 1
  • 31
  • 45
Bogdan Alexandru
  • 5,394
  • 6
  • 34
  • 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
  • 27,472
  • 11
  • 50
  • 75