|
From: Abhijit S. <mu...@gm...> - 2003-08-04 20:35:01
|
> Hi!
>
> Again, a question. Suppose I have a structure like this:
>
> typedef struct _block{
> int array[16][16];
> int v1;
> int v2;
> }block;
>
> So, my question is, is that array[16][16] stored linearly in the
> structure? Can I do a memcpy directly on it, to copy it elsewhere, like
> this:
M$ says Yes.
From MSDN:
-- cut here --
int prop[3][4][6];
...
i = prop[2][1][3];
This statement is a more complex reference to an individual element of prop.
The expression is evaluated as follows:
The first subscript, 2, is multiplied by the size of a 4-by-6 int array and
added to the pointer value prop. The result points to the third 4-by-6 array
of prop.
The second subscript, 1, is multiplied by the size of the 6-element int
array and added to the address represented by prop[2].
Each element of the 6-element array is an int value, so the final subscript,
3, is multiplied by the size of an int before it is added to prop[2][1]. The
resulting pointer addresses the fourth element of the 6-element array.
The indirection operator is applied to the pointer value. The result is the
int element at that address.
-- cut here --
Multi-line URL follows:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html
/_clang_multidimensional_arrays.asp
--
Abhijit Shylanath
Homepage: http://mudeth.tripod.com/
|