Sum of all elements of a list in C
<p>I need to get the sum of a list that only contains doubles.
For some reason that doesn't work, though:</p>

<pre><code>double sum(DoubleList* list) {
    DoubleNode *next = NULL;  
    double sum = 0;
    for (DoubleNode *n = list-&gt;first; n != NULL; n = next) {
        sum += n-&gt;value;
    }
    return sum;
}
</code></pre>