dforte
October 26th, 2001, 09:02 PM
hello, i need some help, i need to have each index in a single array point to a double array. please help.
thanks.
- dima
thanks.
- dima
|
Click to See Complete Forum and Search --> : array point to array dforte October 26th, 2001, 09:02 PM hello, i need some help, i need to have each index in a single array point to a double array. please help. thanks. - dima James Curran October 27th, 2001, 12:22 AM 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. dforte October 27th, 2001, 12:56 AM Sorry, i actually meant a 2 dimensional array. but thanks dforte October 27th, 2001, 01:06 AM 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 James Curran October 27th, 2001, 01:13 AM 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. dforte October 27th, 2001, 01:28 AM thanks, this helps a lot codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |