CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    2

    Arrow how to allocate lagre array dynamically

    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 : [email protected]

  2. #2
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Cool Re: how to allocate lagre array dynamically

    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 !

  3. #3
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: how to allocate lagre array dynamically

    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.
    "Programs must be written for people to read, and only incidentally for machines to execute."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured