hello, i need some help, i need to have each index in a single array point to a double array. please help.
thanks.
- dima
Printable View
hello, i need some help, i need to have each index in a single array point to a double array. please help.
thanks.
- dima
Define "double array". An array of doubles? or a 2-dimensional array?
I'll do the former; It's easier:typedef double DOUBLE10[10]; // Double10 is an array of 10 doubles.
DOUBLE10 LotsODoubles[5];
// LotsODoubles is a array of 5 DOUBLE10,
// each of which is an array of 10 doubles
//
double d = LotsODoubles[2][4];
Truth,
James
http://www.NJTheater.com
http://www.NovelTheory.com
I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.
Sorry, i actually meant a 2 dimensional array. but thanks
if you happen to know how to do the 2 dimensional arrays linked to the indexes of a 1 dimensional array, i would be very grateful.
- Dima
Not a problem, each follwo the pattern:
typedef int DIM1[10]; // DIM1 is a 1-dimension array.
typedef DIM1 DIM2[10]; // DIM2 is a 2-dimension array (an array of DIM1s)
DIM2* pArray = new DIM2[n]; // pArray is an 3-dimension array (an array of DIM2s)
// (Note that pArray is an actuall array, while DIM1 and DIM2 are just types)
// alternately:
//
DIM2** pArray2 = new DIM2*[n];
// pArray2 is an array of pointers to DIM2s
for(int i =0; i< n; i++)
pArray[ i ] = new DIM2;
// don't forget to delete each item.
Truth,
James
http://www.NJTheater.com
http://www.NovelTheory.com
I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.
thanks, this helps a lot