title: What is wrong with using a function that takes an array pointer when trying to assign elements to it?
body: <p>I have been blocking for a while now on a function whose purpose is to assign a value to the respective cells of the sent pointed array:</p>
  
  <pre><code>void assign(T** pointerArray, U linkedListOfValues) {
      size_t i = 0;
      while (linkedListOfValues != NULL) {
          *pointerArray[i++] = convert(linkedListOfValues-&gt;current); // Crash here, when add a second (or more) item
          linkedListOfValues = linkedListOfValues-&gt;next;
      }
  }
  </code></pre>
  
  <p>As commented in the code, when I add more than one element to this pointed array, the program stops. There is no error message or warning. I use this function as such:</p>
  
  <pre><code>T* array = malloc(size * sizeof(T));
  assign(&amp;array, myLinkedList);
  </code></pre>
  
  <p><code>size</code> represents the number of elements present in the linked list, and returns a correct value; the types used (<code>U</code> and <code>T</code>) are very arbitrary, and the <code>convert</code> function converts an element of type <code>U</code> into an element of type <code>T</code>.</p>
  
  <p>The tests I performed did not find any errors in the <code>convert</code> function and in the dynamic allocation.</p>
  
  <p>When I try without using this function, the program works correctly:</p>
  
  <pre><code>T* array = malloc(size * sizeof(T));
  size_t i = 0;
  while (linkedListOfValues != NULL) {
      array[i++] = convert(linkedListOfValues-&gt;current);
      linkedListOfValues = linkedListOfValues-&gt;next;
  }
  </code></pre>
  
  <p>I don't understand what makes my function crash, since I only make a reference, using pointers, to the initial array. What's my mistake?</p>
  
  <p>Ps: I started the C again a little while ago, maybe the solution is obvious, excuse me if that's the case.</p>