title: array elements cannot be modified c++
body: <p>The knots elements in the array is not modified, the print out is always 0 for every elements, why is that?</p>
  
  <pre><code>double* knots;
  knots = (double*)malloc(sizeof(double) * numKeys);
  // Initializaiton
  for (int i = 0; i &lt; numKeys; i++) {
      knots[i] = 0;
  }
  // assign value
  for (int i = 0; i &lt; numKeys; i++) {
      knots[i] = -1 + i;
      printf("%d\n", knots[i]);
  }
  </code></pre>