Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Cocoa multi-dimensional arrays

Cocoa multi-dimensional arrays
Thread Tools
Fresh-Faced Recruit
Join Date: Jul 2002
Status: Offline
Reply With Quote
Sep 17, 2002, 05:36 PM
 
I'm having some trouble declaring a multi-dimensional array of doubles in Cocoa using 10.1.5.

double d[10][10]; works fine, however larger sizes cause a crash.

For instance, double d[256][256]; will compile but result in EXC_BAD_ACCESS.

Is there another step I need to take when allocating memory for these arrays?
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Sep 17, 2002, 11:10 PM
 
Originally posted by frogstar:
I'm having some trouble declaring a multi-dimensional array of doubles in Cocoa using 10.1.5.

double d[10][10]; works fine, however larger sizes cause a crash.

For instance, double d[256][256]; will compile but result in EXC_BAD_ACCESS.

Is there another step I need to take when allocating memory for these arrays?
Try using Objective-C++:

double *d[][] = new double[256][256];

Just a thought.


I've always had problems with multidimensional arrays (C, C++, etc...). I tend to use single dimensional arrays and create a wrapper class to create the illusion of multiple dimensions. I have a matrix class, for example. The implementation is a single dimensional array, but you use it the same as any 2d matrix.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:47 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2