• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Declaring and initialization of C array.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Declaring and initialization of C array.


  • Subject: Declaring and initialization of C array.
  • From: JAMES ROGERS <email@hidden>
  • Date: Wed, 01 Jun 2011 10:12:32 -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 of a cocoa project, the compile will fail with the following:

	/Users/jimrogers_w4atk/Development/workspace/ArrayTest/ArrayTestAppDelegate.h:14:0 /Users/jimrogers_w4atk/Development/workspace/ArrayTest/ArrayTestAppDelegate.h:14: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token

I would really like to use a simple C array as the example above. Any help would be appreciated.

JIM ROGERS
email@hidden
http://web.me.com/jimrogers_w4atk

_______________________________________________

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

  • Follow-Ups:
    • Re: Declaring and initialization of C array.
      • From: Graham Cox <email@hidden>
  • Prev by Date: touches outside a view's bounds
  • Next by Date: Re: Declaring and initialization of C array.
  • Previous by thread: Re: touches outside a view's bounds
  • Next by thread: Re: Declaring and initialization of C array.
  • Index(es):
    • Date
    • Thread