FROM : Guy English
DATE : Wed Nov 17 18:55:27 2004
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_removed>> 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_removed>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/guy.<email_removed>
>
> This email sent to guy.<email_removed>
>
DATE : Wed Nov 17 18:55:27 2004
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_removed>> 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_removed>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/guy.<email_removed>
>
> This email sent to guy.<email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Lorenzo | Nov 17, 11:21 | |
| Guy English | Nov 17, 18:55 |






Cocoa mail archive

