Returning a pointer to the beginning of a linked list after adding nodes?
<pre><code>struct node {
    struct node *next;
    int num;
} Node;


Node *insert(int i) {
    Node *head;
    for (int c = 0; c &lt; i; c++) {
        head = malloc(sizeof(Node));
        head.num = i;
        head = head-&gt;next;
    }
}
</code></pre>

<p>The insert function is supposed to create a linked list and add numbers from 0 to i to that linked list. However, it is also supposed to return a pointer to the beginning of the list/the list itself and I can't seem to figure out how to do it. I've tried to make a pointer and set it equal to head after adding the first node, but it only returns the first node and not the entire list. Can someone please help? Thanks.</p>