Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zerosignull

using new[] to cre8 multi demensional arays

This topic is 6187 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i use the new[] operator to cre8 a multi dimensional array??? ie int myArray[2][2]; int *myDynamicArray; myDynamicArray = new myDynamicArray[2][2]; //doesnt work ~prevail by daring to fail~

Share this post


Link to post
Share on other sites
Advertisement
Hi

You have to use function malloc

However in this case, won''t help you much
because array[x][x] have special struct

Whatsoever in c/c++ saying somewhere in code (main or WinMain)

int array[2][2]

is already a dynamic reservation,...

I really hope i helped you


Share this post


Link to post
Share on other sites
Try this:

  
int **myDynamicArray = NULL;
int x = 2;
int y = 2;

myDynamicArray = new int * [x];
for(int i = 0;i < x;i++)
{
myDynamicArray[i] = new int [y];
}


hope that helps.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ITH3 is right,
but may also use this...

int (*myDynamicArray)[2];
myDynamicArray = new float[2][2];

ccc...





Share this post


Link to post
Share on other sites
Guest Anonymous Poster
ITH3 is right,
but may also use this...

int (*myDynamicArray)[2];
myDynamicArray = new int[2][2];

ccc...





Share this post


Link to post
Share on other sites
ITH3 is right,
but may also use this...

int (*myDynamicArray)[2];
myDynamicArray = new int[2][2];

ccc...





Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!