Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-dimensional pointer arrays

Status
Not open for further replies.

merrimanjd

Programmer
Jul 30, 2002
1
US
Hello,

I am having some trouble using multidimensional arrays with pointers. I am able to create the array whatever size I want with this code from
float (*temp)[3];

temp = new float[2][3];
temp[0][0] = 2.345;
...

The only important differences are that I am not using floats, I am using a type of my own creation, and the user decides the size of the array in the program. I am new to creating arrays like this and don't know how to do a couple of things:

1. I know that if I create a multidimensional array the 'normal' way, then in function prototypes I have to explicitly give the sizes of all but the first dimension. What am I supposed to do if all the dimensions unknown until run-time?

2. Also on the idea of functions, could someone give me examples of function calls and bodies besides the prototype?

3. Is there anything else I should know about using this kind of array?

I am using Borland's command line C++ compiler.

Thanks,

Jesse Merriman
jesse_m14020@yahoo.com
 
Have you ever looked into linked lists?
They are pretty helpful for dynamically sized arrays.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top