Re: Declaring and initialization of C array.
Re: Declaring and initialization of C array.
- Subject: Re: Declaring and initialization of C array.
- From: Graham Cox <email@hidden>
- Date: Thu, 02 Jun 2011 01:17:06 +1000
On 02/06/2011, at 1:12 AM, JAMES ROGERS wrote:
> K&R says to declare and initialize an array in C:
>
> int myArray[2] = {1,2};
>
> If the above is entered into the .h file
That's because a .h file is the HEADER.
You need to put this in the BODY, which is the .c (pure C) or .m (Obj-C) file. The reason is that the = {1,2} part is executable code, not just a declaration, so it needs to live somewhere.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden