I have a 2D array that I'm dynamically allocating at runtime, like so
accData = calloc(nbox, sizeof(double *));
for(bb = 0; bb < nbox; bb++)
accData[bb] = calloc(usedTime * usedChan, sizeof(double *));
and I want to only pass the second dimension to my function. This array represents data defined in several different "boxes", and for each box, I want to pass the relevant information to the function, process it and store it in the same array. Currently this is how I'm doing it -
for(bb = 0; bb < nbox; bb++)
fftAndsubtract(accData[bb], ntime, nchan, nsigma, bb);
where fftAndSubtract
performs an FFT (fast fourier transform) and a few other operations. The function definition is like so:
int fftAndsubtract(double accData[], ntime, nchan, nsigma, bb);
but accData
doesn't seem to hold the modified values that fftAndSubtract
produces. I've verified this, because I'm printing the outputs of the operations done in the function itself. The compiler isn't complaining, so I didn't think this was wrong. Is there a better way to do this?
Question: Is there a way I can pass accData[bb]
to the function so that the output of the operations done by the function are stored in the same array?