Re: Very Basic question
Re: Very Basic question
- Subject: Re: Very Basic question
- From: Guy English <email@hidden>
- Date: Wed, 17 Nov 2004 12:55:27 -0500
float *gPoints;
gPoints = (float*)malloc( 8 * totPoints * sizeof( float ) );
General answer:
2D arrays are the size of one dimension multiplied by the size of the
second dimension multiplied by the size of each element. Think of it
like the area of a rectangle.
On Wed, 17 Nov 2004 11:21:24 +0100, Lorenzo <email@hidden> wrote:
> Hi,
> I would like to initiate an array of floats with 2 dimensions like
>
> float gPoints[8][totPoints];
>
> But I would like to use "malloc" so I can use this variable as global in my
> class, and use free(gPoints) when release the object.
> Also, the variable totPoints changes all the time, so I really need to
> delete and recreate gPoints all the time.
> I already know how to create the array with one dimension only, with malloc.
>
> float *gPointsX = malloc(sizeof(float) * totPoints);
>
> So, how to do the same with a two dimensional array?
> Sorry for the very basic question, but I forgot how to do it.
>
> Best Regards
> --
> Lorenzo
> email: email@hidden
>
> _______________________________________________
> 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
>
_______________________________________________
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