This is my code in plain old C. I want to add each column of the data. For example, 28+518+917, 34+512+914, et.al.:
short rawdata[][20]={
28,34,36,39,42,47,37,41,41,33,33,36,36,36,27,27,24,31,29,26,
518,512,507,508,521,522,524,525,519,512,506,511,511,501,501,495,497,500,508,504,
917,914,905,909,892,879,869,873,876,877,875,870,883,893,893,884,881,882,885,888
};
int aae( int nLenFrame, short **psDataBuffer, float *pFV )
{
float sum = 0.0;
int i=0, j;
for (j=0; j<AXES; j++)
{
printf("Component: %d\n", *(*(psDataBuffer +j) + i));
}
return 1;
}
int main(int argc, char *argv[]){
int arraySize;
float pFV;
int a;
arraySize = sizeof(rawdata)/sizeof(int);
a = aae( arraySize, rawdata, &pFV );
printf("aae = %f\n", pFV);
}
I'm trying to pass rawdata
to function aae
but when I compile, I get the following errors/warnings from gcc, which naturally, crash my code. How should I pass rawdata
into aae
?
$ gcc aae.c -o aae
aae.c: In function ‘main’:
aae.c:31:2: warning: passing argument 2 of ‘aae’ from incompatible pointer type [enabled by default]
a = aae( arraySize, rawdata, &pFV );
^
aae.c:13:5: note: expected ‘short int **’ but argument is of type ‘short int (*)[20]’
int aae( int nLenFrame, short **psDataBuffer, float *pFV )
^
Thanks in advance for any help.