[CSI] Question about initial value of multi array

Mikhail Nesterenko mikhail at cs.kent.edu
Thu Dec 6 14:28:31 EST 2018


> 
> When we declare a boolean multiarray such as a[3][3], what will be the
> initial value for all the elements? The google says they will all be set to
> false by default. However, if I don't do "bool a[3][3]={false}", I'll just
> get funny results after running the code.

The initial values for the multidimensional array are arbitrary unless
the array is initialized. To set them all to false you can do this:

bool a[3][3] = {{}}; //  note the second set of braces.

Thanks,
--
Mikhail


More information about the cs13001 mailing list