Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCHAR wszFoo[CONSTANT_BAR] = {0}; <-- What does {0} mean?

Tags:

c++

WCHAR wszFoo[CONSTANT_BAR] = {0}; 

I've never seen something like {0} used in C++ as part of the language. And I have no idea how to search for a question like this online. What is it?

like image 311
Marcus Avatar asked Dec 10 '22 14:12

Marcus


1 Answers

See array initialization.

Missing initialization values use zero

If an explicit array size is specified, but an shorter initiliazation list is specified, the unspecified elements are set to zero.

float pressure[10] = {2.101, 2.32, 1.44};

This not only initializes the first three values, but all remaining elements are set to 0.0. To initialize an array to all zeros, initialize only the first value.

like image 87
Aillyn Avatar answered Dec 12 '22 04:12

Aillyn