Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initializing a multidimensional array: {0} versus {{{0}}}

In the C code I am analyzing, there are a lot of multidimensional (struct) arrays which are initialized with a different number of curly brackets e.g. {{0}} or {{{0}}}.

However, replacing these by {0} also works perfectly.

Is there a (functional) difference between using one or more sets of curly brackets ({}) occurrences ?

like image 634
Michel Keijzers Avatar asked Sep 09 '25 19:09

Michel Keijzers


1 Answers

No, there is no functional difference. The C standard allows to leave out intermediate {}. In particular, the form { 0 } is an initializer that can be used for all data types.

like image 84
Jens Gustedt Avatar answered Sep 12 '25 14:09

Jens Gustedt