C adding a structure to an array of structures with a constant value
<p>I have an assignment where we need to take an unspecified list of numbers, display an unsorted doubly linked list, quicksort it, and display the sorted list.</p>

<p>Here is the main:</p>

<pre><code>void main()
{
    int i =0;
    int c = 0;
    int *j = malloc(sizeof(int));
    int temp;
    int *k = malloc (sizeof(int));
    struct _myNode *a = malloc (sizeof(struct _myNode));
    printf("\nEnter the list to be sorted : ");
    while(1)
    {   
        scanf("%d",j);
        if (*j == 0)
        {
            free(j);
            break;      
        }
        else
        {       
            temp = *j;  
            c++;
            printf("C = %d ", c);
            a = realloc(a, c*sizeof(struct _myNode));
            if(i &gt; 0)
            {
                struct _myNode newNode = { temp, NULL, &amp;a[i-1] };
                a[i] = newNode;
                a[i-1].next = &amp;a[i];
            }
            else 
            {
                struct _myNode newNode = {  temp, NULL, NULL };
                a[i] = newNode;
            }
            ++i;

        }
    }

    printf("\nUnsorted list is : ");
    for(i = 0; i &lt; c; i++)
        printf("%d ", a[i].value);


    //quickSort(a, 0, c-1);

    //printf("\nSorted array is: ");
    //for(i=0; i &lt; c; i++)
    //  printf("%d ", a[i]);
    //printf("\n");
}
</code></pre>

<p>And here is the header</p>

<pre><code>#ifndef NODE_H_
#define NODE_H_

struct _myNode{
    int const value;
    struct _myNode *next;
    struct _myNode *prev;
};

struct _myNode* quicksort(struct _myNode *head);

void printlist(struct _myNode *head);

#endif
</code></pre>

<p>When I try to compile, I am getting the error <code>assignment of read-only location ‘*(a + (sizetype)((long unsigned int)i * 24ul))’</code> at the <code>a[i]=newNode;</code> lines. From what I've been able to find, the error is due to the <code>int const value</code> element of the structure. That is one of the requirements of the assignment and therefore cannot be changed. How do I give the array a[i] the proper inputted values? I've tried doing 
<code>a[i] = { temp, NULL, NULL }</code>  and I just get <code>error: expected expression before '{' token</code></p>