hi guys...
im having a problem figuring out exactly how to fill a dynamically allocated array of doubles.
bool getData(double **x, double **y, int n)
my function is passed these two pointers to pointers and, in the end, they are supposed to point to the addresses of dynamically allocated arrays of n doubles.
Im at a complete loss of how to do this...
I figured that doing something like:
*x = new double[n];
*y = new double[n];
would create the arrays successfully and theeen in order to access each element of the array, i would be able to do somethjing like
cin>>*x[index];
BUT this doesnt work.... I know that normally, it would be easier to probably not have pointers to pointers but i have to adhere to this rule..
You might find it interesting to know that from the main function, my get data function is called like this:
double *xarr = NULL; // Pointer to array of x coordinates
double *yarr = NULL; // Pointer to array of y coordinates
getData(&xarr, &yarr, num);
I can post more code if necessary. Ive tried more than just the non working suggestion i posted here but nothing seems to work..