float* ThreeValueMovingAverage(float* numbers, int count) {
average = newfloat[count];
for(int i = 1; i < count-1; i++) {
average[i] = (numbers[i-l] + numbers[i] + numbers[i+1]) / 3.0f;
}
return average; //missed that in your code
}
The problem is on the edge cases of the loop. When i = 0, part of your statement is numbers[i-1], which will be numbers[-1]. What I posted will make it work, but probably not in the way you want. You need to add some other behavior on the edge cases (i = 0, i = [the last element]).