Reputation: 5542
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?
Upvotes: 1
Views: 270
Reputation: 28050
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.
Upvotes: 2