Click to See Complete Forum and Search --> : how to allocate lagre array dynamically


Dharmendra
May 16th, 2005, 06:31 AM
hi

i have problem regarding memory allocation.i want to allocate the for 3 such pointer of array. float *a[264],float *b[264],float *[264]. i used this as
for(int i=0;i<264;i++)
{
direc1[i]=new float[296];
if(direc1[i]==NULL)
{
cout<<"There is only"<<i<<"spaces";
getch();
exit(0);
}
for(int j=0;j<296;j++)
{
dirf>>dir;
direc1[i][j]=dir;
}
}
here dirf as file object . when i compile it it compiled successfully.when i ru the it tkaes file name and show the ... There is only 47 spaces.
I am using p4 system with 256 RAM and 40 Gb HDD. PLz any body get the solution plz send it to me

My mail id : dkcool2@rediffmail.com

exterminator
May 16th, 2005, 07:19 AM
What are you trying to do over here? The various variables being used over here are not even defined? Could please paste a complete code?

U say u have defined 3 arrays - a, b and probably c - never used???

By the way .. there is no need to check for NULL once u use new to allocate the memory. It throws an exception if its unable to serve its purpose.

Suggestion - Review ur query !

RoboTact
May 16th, 2005, 11:25 AM
It doesn't seem to be that huge array: only 256Kb. Except for very dirty style, in principle this code seems OK. Try to create a small self-sufficient code snipped producing the error.