2 Replies - 2556 Views - Last Post: 03 November 2007 - 10:26 PM Rate Topic: -----

#1 Abhishek0402   User is offline

  • New D.I.C Head

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

How to create double dimension dynamic array?

Post icon  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   User is online

  • Dreaming Coder
  • member icon


Reputation: 7183
  • View blog
  • Posts: 14,971
  • Joined: 16-October 07

Re: How to create double dimension dynamic array?

Posted 03 November 2007 - 08:11 PM

View PostAbhishek0402, 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.
Was This Post Helpful? 0
  • +
  • -

#3 jjhaag   User is offline

  • me editor am smartastic
  • member icon

Reputation: 48
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1