title: C++ - Creating a Low Pass Filter Function of Array
body: <p>So I am supposed to take an array of integers, and a window size and "smooth the values of the array out. Meaning, it does this by taking the average of x values before and x values after a particular number and replacing that number with that average in a new array. Example, input array of {3,4,1,4,3,7,8} with a window size of 3. First and last values would be 0 as the window cannot extend before/after the array.</p>
  
  <p>Here's my code</p>
  
  <pre><code>int *lowPassFilter(int arr[], int windowsize) {
  
      // initialize new array to be returned
      int *newarray[(sizeof(arr)/sizeof(arr[0]))];
  
      for (int i = 0; i &lt; (sizeof(arr)/sizeof(arr[0])); i++) {
          if (arr[i] == arr[0]) {
              newarray[0] == 0;
          } else if (arr[i] == arr[sizeof(arr)/sizeof(arr[0])]) {
              newarray[sizeof(arr)/sizeof(arr[0])] == 0;
          } else if (((arr[i] - windowsize) &lt; windowsize) || ((arr[i] + windowsize) - sizeof(arr)/sizeof(arr[0])) &lt; windowsize) {
              newarray[i] == 0;
          } else {
              newarray[i] == ((arr[i - ((windowsize - 1) / 2)] + (arr[i - ((windowsize - 1) / 2) + 1])
              + arr[i] + (arr[i + ((windowsize - 1) / 2)]) + (arr[i + ((windowsize - 1) / 2) + 1])) / 2);
          }
      }
      return newarray;
  }
  
  int main() {
      int g = rand() % ((7 - 3) + 1) + 3
      int test[] = rand()
      lowPassFilter(test, g);
  }
  </code></pre>
  
  <p>The window size must be a value between 3 and 7, and the inputted array must be randomly generated.</p>
  
  <p>I'm really stuck as how to fix this function. What I have does not compile. Any help would be appreciated.</p>