|
From: Ioannis V. <iv...@em...> - 2003-08-04 22:40:02
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of OROSZI Bal?zs
> Sent: Monday, August 04, 2003 5:34 PM
> To: dev...@li...
> Subject: [Dev-C++] arrays in structures
>
>
> 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:
>
> memcpy(destination->array,source->array,16*16*sizeof(int));
> /* destination*/ /* source*/ /* bytes to copy */
>
> Can I do this?
Yes. But always be careful all the elements of the array to be in the
"automatic storage" (I assume C here) as it is in your case, and not
something like:
int *array[16];
/* ... */
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|