Archived

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

Dynamic 3D Array

This topic is 6571 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

I think it goes something like this:

int ***map;

map = new int**[3];

for (int i = 0; i < 3; i++)
{
map[i] = new int*[100];

for (int j = 0; j < 100; j++)
map[i][j] = new int[100];

}


Then you can use it normaly.

You may also want to remember to delete it too :-)

I think a better way would be to write a special class to handle what you have in mind.

[This message has been edited by Bugdude (edited December 23, 1999).]

Share this post


Link to post
Share on other sites
Is there a way to create a 3D array at runtime? I tried what I thought would work, which is:

int *map;
map = new int[3][100][100];

but it didnt work...

so how would I go about doing this? or is there a better way to accomplish this?

thanks!

------------------
Luis Sempe
visuallr@guate.net
http://www.geocities.com/SiliconValley/6276


Share this post


Link to post
Share on other sites