Mail Archives: djgpp/2002/02/17/17:41:12
X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f
|
Message-ID: | <000701c1b73a$e072f160$17d97689@computer>
|
From: | "William and Lorie Thex" <lwthex AT rangeweb DOT net>
|
To: | <djgpp AT delorie DOT com>
|
Subject: | RE:re array of arrays
|
Date: | Sat, 16 Feb 2002 15:39:19 -0700
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook Express 5.50.4807.1700
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4807.1700
|
Reply-To: | djgpp AT delorie DOT com
|
> sorry, I'll clarify the previous post
>
> I have an array. Lets call this arr. The array has, lets say, 5 elements
> so.. it looks like this
> __________________________________________
> |________|________|________|________|________|
>
> now... inside EACH of these array elements, I would like to have more
> arrays, lets say 4 elements in size.. so it would look like this
>
> __________________________________________
> |________|________|________|________|________|
> ___ ___ ___ ___ ___
> |___| |___| |___| |___| |___|
> |___| |___| |___| |___| |___|
> |___| |___| |___| |___| |___|
> |___| |___| |___| |___| |___|
>
> So now, I would like to access, say, the 3rd element in the array, that is
> inside of the 2nd array (arr). eg.
>
> __________________________________________
> |________|___2____|________|________|________|
> ___ ___ ___ ___ ___
> |___| |___| |___| |___| |___|
> |___| |___| |___| |___| |___|
> |___| |_3_| |___| |___| |___|
> |___| |___| |___| |___| |___|
>
>
> Now, I would not like to code this, mutlidimensionally. eg arr[5][4]..
> because the rest of my coding wouldn't be compatible..
The way that I understand an "array of arrays" and multidimensional
arrays in C is that they are basicly synonymous with one another.
So, in a sense, you would have to
"code this mutlidimensionally. eg arr[5][4].."
Or: int *arr[23];
Which is an array of 23 pointers to int.
With this array of pointers you would have to take care of the memory
requirements dynamicly.
But even then you would access them like you would in a multidimensional
array.
Or something like : *(*(arr + x)) = number; during assignment, or
printf("%d", *(*(arr + x)) ); to access them.
I hope this was helpful.
William
- Raw text -