I am trying to learn C. I am new to C programming. I have the following function.
/*dA would be a pointer to a 2D array*/
void normalizeCols(float* dMu, float* dSigma, float* dB, float* dA, int n){
int col, row;
for(col=0; col < n; col++)
/*Step 1: calculating mean*/
float tempMu = 0.0;
dMu = &tempMu;
for (row=0; row < n; row++){
/*I am adding all the elements of the column*/
dMu += *(*(dA+row)+col); //ERROR: operand of * must be a pointer
}
/*dividing dMu by number of dimension(square matrix)*/
dMu /= (float) n; //ERROR: expression must have arithmetic or enum type
//More code here
}
}
I am trying to find the mean of a column. I get those two errors that I have commented in the above snippet. How should I fix this?
dA += dA[row][col]?dA? Or are you trying to add something to the value of*dA? There's at least two completely different ways ways to "fix" your code. Nobody knows which one is the correct one until you explain what you are trying to do.