Re: Declaring and initialization of C array.
Re: Declaring and initialization of C array.
- Subject: Re: Declaring and initialization of C array.
- From: John Joyce <email@hidden>
- Date: Wed, 01 Jun 2011 10:25:24 -0500
>> 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
In other words, you should *declare* things in the .h file and executable statements should be in the .c or .m or .mm files etc...
_______________________________________________
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