Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!motcsd!mcdcup!mcdchg!marcal!odgate!mike From: mike@odgate.odesta.com (Mike J. Kelly) Newsgroups: comp.lang.c Subject: Re: Think C: dynamic 2d array allocation Keywords: Think C, dynamic allocation Message-ID: <1991Apr25.205726.21860@odgate.odesta.com> Date: 25 Apr 91 20:57:26 GMT References: Organization: Odesta Corporation, Northbrook IL. Lines: 18 In article frost@watop.nosc.mil (Richard Frost) writes: >I am trying to dynamically allocate space for a 2d array USING Think C 4.0 >(on a Macintosh IIci). Here's what I've tried: > >------------------------ >#define max_el 128 >#define max_az 2048 > >int el, az; >unsigned int **image; > > **image = (unsigned int **) malloc(max_el * sizeof(unsigned int *)); ^^ this deferences an undefined pointer. **image is of type unsigned int, but you're assigning a pointer to pointer value to it. What I think you want is: image = (unsigned int **) malloc(max_el * sizeof(unsigned int *));