slashman wrote:
I recently came across code that looked like this
float i = {1.0};
Can anyone tell me the significances of the curly braces{}.
Thanks in advance
Vivek
It's redundant for this particular initialisation, but if i were to be
an array of float then you'd need the curly braces to initialise one or
more of it's elements. Ex:
float arr[5] = { 1.0, 2.0, 3.0 };
Elements arr[0], arr[1] and arr[2] are initialised with 1.0, 2.0 and 3.0
respectively while the remaining elements are set to zero by the
compiler. This is true only for statically allocated arrays.