954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dynamic Array and Pointer

If we don't know the size of the array before running, usually we use the dynamic allocation.
My question is when I already define and allocate memory for a pointer to two-dimensional array, may I directly use the array expression A[i][j] to this pointer as I showed as following?
Borland C++6.0 doesnot accept this expression with error messsage of" invalid indirect". But BCB2006 seems works.

fftw_complex  *in1,*out1;
in1 = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*mFFTSize);
out1 = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*mFFTSize);
for( int j = 0; j < fNumSample; j++ ) {
 in1[j][0] = fTestdata[channel][j];  //one channel one trial data
 in1[j][1] = 0;
}

So, what I really want to know is what is the best way to define and use multiple-dimension arrays in this situation? And as a function argument, which is the best efficient way to define and pass multiple-dimension array?

yuelabtina
Newbie Poster
6 posts since Jun 2006
Reputation Points: 13
Solved Threads: 0
 
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You