PDA

View Full Version : --also--



hatemagnet
02-09-2002, 06:48 PM
Speaking of 2-d arrays on the last topic, does anyone know a simple way to create a dynamic 2-d array?

02-09-2002, 08:21 PM
ha ha ha ha ha ha

Bob
02-10-2002, 02:48 AM
Here's a piece of code to create a 20x30 array dynamically.



char **dynamic2DArray;
dynamic2DArray = new char *[20];
for(int i = 0; i < 20; ++i)
{
dynamic2DArray[i] = new char[30];
}

You access it as dynamic2DArray[x][y], where x is between 0 and 19, and y between 0 and 29.

hatemagnet
02-11-2002, 05:12 PM
Thanks Bob. That is very useful information.