I have written a function to accept an array of floats and then find the index of the minimum value:
Elsewhere, I declare the array and call the function. (Contents of "errors" are populated elsewhere. "index" is also declared elsewhere)
As I understand it, when an array is passed to a function in C, it is actually a pointer to the first element that gets passed. However, my compiler is warning me that:
Is this safe to ignore or am I actually doing something wrong? The code appears to function as I intended.
Code:
int minimum(float * array, int size)
{
float minimum = *array;
int index = 0;
int x = 0;
for(x=0; x<size; x++)
{
if(*array < minimum)
{
minimum = *array;
index = x;
}
array++;
}
return index;
}
Code:
float errors[8];
index = minimum(&errors, 8);
Code:
Description Resource Path Location Type
#169-D argument of type "float (*)[8]" is incompatible with parameter of type "float *" control.c /Two_Step_FCS_MPC/controlLogic line 151 C/C++ Problem