View Full Version : I have never seen this

Aug 19, 2012, 05:50 AM
I have been using Objective C to make Apps for 8 months now, and I have never seen this before.

What's going on here?

int version[] = {0};

Aug 19, 2012, 06:26 AM
This is a plain C array initialization. For some reason the author is initializing a one-element array of int. The syntax is a little more obvious when initializing an array with more than one element, e.g.

int myThreeElementArray[3] = {1,2,3};

will initialize an array of 3 ints with values 1,2,3. Since the right-hand-side contains explicit values, you could also omit the size and get the same result with

int myThreeElementArray[] = {1,2,3};

On the other hand, if you omit the explicit initializer, you'd have to specify the size.

Aug 19, 2012, 10:45 AM