Re: [Dev-C++] Multidimensional arrays and memory leaks
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jorge A. <jor...@ep...> - 2004-08-10 17:34:09
|
First, allocate the "pointers" array, and then allocate the arrays=20
inside. In C:
number=3D(float **)malloc(2*sizeof(float *));
...
int i;
for(i=3D0;i<50000;i++){
*(number+i)=3D(float *)malloc(sizeof(float));
...
}
and so on.
tay...@dd... escribi=F3:
>Hi,
>
>Since I tried to use a 2D array "number[50000][2]" I started to have ran=
dom=20
>crashes at run time and debugging.=20
>
>I guess this is a memory handling problem (what do you think?). Thus, I =
tried
>to put the array in the heap (would that help?). However I tried many wa=
y to do=20
>it without success.=20
>
>I declared the array in the header of a class as:
>
>float number[][];
>
>Then I tried to put it in the heap using GlobalAlloc in the constructor.=
=20
>
>
>Could anybody give me a hand? Thanks a lot.
>
>Jorge=20
>
>
>---------------------------------------------
>This message was sent using Endymion MailMan.
>http://www.endymion.com/products/mailman/
>
>
>
>
>-------------------------------------------------------
>SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
>100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
>Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
>http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> =20
>
|