• 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
Re: multidimensional arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multidimensional arrays


  • Subject: Re: multidimensional arrays
  • From: Andy Armstrong <email@hidden>
  • Date: Mon, 14 Mar 2005 20:25:15 +0000

On 14 Mar 2005, at 19:56, Serge Meynard wrote:
You do realize that C fully supports multi-dimensional arrays, you can do myArray[x][y] in plain C (and Objective-C is super set of C).

Only if your array size is fixed at compile-time. I'm talking about arrays whose size is only known at execution time, and are allocated dynamically.

#include <stdlib.h>

int main(void) {
    int **x, i;
    x = malloc(10 * sizeof(int *));
    for (i = 0; i < 10; i++) {
           x[i] = malloc(10 * sizeof(int));
    }

    x[0][0] = 1;

    return 0;
}

Looks pretty dynamic to me :)

--
Andy Armstrong, hexten.net

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >multidimensional arrays (From: Daniel Child <email@hidden>)
 >Re: multidimensional arrays (From: Serge Meynard <email@hidden>)
 >Re: multidimensional arrays (From: Shawn Erickson <email@hidden>)
 >Re: multidimensional arrays (From: Serge Meynard <email@hidden>)

  • Prev by Date: NSTableDataSource and Key-value Coding
  • Next by Date: Re: NSTableDataSource and Key-value Coding
  • Previous by thread: Re: multidimensional arrays
  • Next by thread: Re: multidimensional arrays
  • Index(es):
    • Date
    • Thread