# How to create double dimension dynamic array?

Page 1 of 1

## 2 Replies - 2538 Views - Last Post: 03 November 2007 - 10:26 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=36734&amp;s=d481a2a321aa88e0ccc5b70a5feda5eb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Abhishek0402

Reputation: 4
• Posts: 28
• Joined: 19-September 07

# How to create double dimension dynamic array?

Posted 03 November 2007 - 07:17 PM

Suppose we have to create a matrix of n*n columns then how to create double dimension dynamic array for that?
Is This A Good Question/Topic? 0

## Replies To: How to create double dimension dynamic array?

### #2 baavgai

• Dreaming Coder

Reputation: 7119
• Posts: 14,840
• Joined: 16-October 07

## Re: How to create double dimension dynamic array?

Posted 03 November 2007 - 08:11 PM

Abhishek0402, on 3 Nov, 2007 - 10:17 PM, said:

Suppose we have to create a matrix of n*n columns then how to create double dimension dynamic array for that?

Meaning a matrix of rows and columns, so the total size would be rows*columns? Depending on the compiler, this kind of referencing is essentially an abstraction to make you feel better. It's really stored as a one dimensional array with index==(rows*row)+column

If you seriously wanted to grow in both directions, you'd make any array of arrays, sometimes called a jagged array, because all the arrays pointed to don't have to be the same length.

Hmm... short answer, make any array of array pointers, then allocate each of those arrays.

Hope this helps.

### #3 jjhaag

• me editor am smartastic

Reputation: 48
• Posts: 1,789
• Joined: 18-September 07

## Re: How to create double dimension dynamic array?

Posted 03 November 2007 - 10:26 PM

Well, you haven't specified your language here (C or C++), but if you search through the snippets sections for each of those languages, you will probably find some examples. And when I say probably, I mean definitely. Unless there are typos in your search. Then I'm not sure what you'll find.