I'm having some issues accessing elements of an array passed into a function.
#define N (128)
#define ELEMENTS(10)
typedef int (*arrayOfNPointers)[N];
So, if this is right, it is a data type describing an array of N
pointers to int
.
I later initialize my arrays individually, like so:
arrayOfNPointers myPtrs = { 0 };
int i;
for (i=0; i<N; i++) {
myPtrs[i] = (int*)malloc(ELEMENTS);
}
However, this fails with the following error:
error: incompatible types when assigning to type 'int[128]' from type 'int *'
So, it seems there is something very wrong in my syntax. But in another chunk of code, where I'm modifying the contents of some such structures, I have no problems.
void doWork(void* input, void* output) {
int i,m,n;
arrayOfNPointers* inputData = (arrayOfNPointers*)input;
int* outputData = (int*)output;
for (m=0, n=0; n<nSamples; n++) {
for (i=0; i<nGroups; i++) {
outputData[m++] = (*inputData)[i][n];
}
}
}
Is this array logic severely broken?