Hello,
I am writing a moving average function, but I am getting the error mentioned in the title. I would like to understand what the error means and how to avoid it.
Here is the code:
// This part resides in the source file
int movingAverage(int *ptrArrNumbers, long *ptrSum, int pos, int len, int nextNum)
{
*ptrSum = *ptrSum - ptrArrNumbers[pos] + nextNum;
ptrArrNumbers[pos] = nextNum;
return *ptrSum/len;
}
// This part resides in my main source file, but it is not "main.c".
// It is something else
if(pos0==arr0Length)
{
arr0Filled = 1;
pos0 = 0;
}
// If the array has not been fully filled we only consider the number of cases filled with a pressure value
// to calculate the average pressure (len0). When the array is filled, len0 is the length of the array
if(arr0Filled == 0)
{
len0=pos0+1;
}
else
{
len0=arr0Length;
}
// Moving average
newAvg0 = movingAvg(arr0Numbers, &sum0, pos0, len0, pressure0);
pos0++;
Thank you