Can't figure out whats the cause of seg fault : <p>Total C noob here. Having difficulty location the cause of this seg fault. I have tried running a debugger the <code>GBD</code> debugger but I can't figure out how to get it working. The function I'm trying to test removes the contents of an array, puts it in a linked list and then puts the values of the linked list into the second array given to the function. Heres my test and function code. </p>

<h3>Test</h3>

<pre><code>int test_transfer(void) {
    #define ARRAY_LENGTH 10
    void *arr1[ARRAY_LENGTH];
    for (int i = 0; i &lt; ARRAY_LENGTH; i++) {
        arr1[i] = &amp;i;
    }

    void *ptr;
    void *arr2[ARRAY_LENGTH];
    for (int i = 0; i &lt; ARRAY_LENGTH; i++) {
        arr2[i] = ptr;
    }

    transfer(arr1, arr2, ARRAY_LENGTH, sizeof(int), add_to_front, remove_from_front);

    for (int i=0; i &lt; ARRAY_LENGTH; i++) {
        printf("%d\n", *((int *)arr2[i]));
    }

    return 0;
}
</code></pre>

<h3>Transfer Function</h3>

<pre><code>void transfer(void **arr1, void **arr2, int length, int size, void (*insert)(List *, void *), void* (*remove)(List *)) {
    List *list = List_create();

    for (int i=0; i &lt; length; i++) {
        (*insert)(list, &amp;arr1[i]);
    }

    for (int i=0; i &lt; length; i++) {
        void *indexPtr = arr2 + i*size;
        indexPtr = (*remove)(list);
    }

}
</code></pre>
