title: Assigning pointer to different pointer (counting sort)
body: <p>I'm having some issues with my implementation of counting sort. I am trying to reassign some pointers, however this does not work. I know I could use a loop to copy the sorted values from "sorted_arr" into my "values" array but I would like to understand why my version does not work. Thanks in advance!</p>
  
  <pre><code>void countingsort(unsigned int *values, unsigned long nofelements) {
      unsigned int *aux_arr;
      unsigned int *sorted_arr;
      unsigned int *temp_arr;
      long i;
  
      aux_arr = calloc((MAXSORTVALUE + 1), sizeof(*aux_arr));
      assert(aux_arr != NULL);
      sorted_arr = malloc(nofelements * sizeof(*sorted_arr));
      assert(sorted_arr != NULL);
  
      for (i = 0; i &lt; nofelements; i++) { 
          aux_arr[values[i]]++;
      }
  
      for (i = 1; i &lt;= MAXSORTVALUE; i++) {
          aux_arr[i] = aux_arr[i] + aux_arr[i - 1];
      }
  
      for (i = nofelements - 1; i &gt;= 0; i--) {
          sorted_arr[aux_arr[values[i]] - 1] = values[i];
          aux_arr[values[i]]--;
      }
  
      temp_arr = values; // here is the reassignment
  
      values = sorted_arr; // and here
  
      free(temp_arr);
      free(aux_arr);
  }
  </code></pre>