Skip to content

Conversation

@adryue
Copy link

@adryue adryue commented May 21, 2025

There seems to be an unintentional error in the code for the linked lists sections. The text explains that the code is supposed to add up the elements of a linked list, yet for all 3 versions of the code (including the "correct code" version), the sum is only assigned to the value in each individual node, not adding up all the values.

I fixed the code by changing
sum = p->data;
to
sum += p->data;
for all 3 versions.

(This wasn't even the error that the example was trying to showcase! I was very confused when I first read through it.)

There seems to be an unintentional error in the code for the linked lists sections. The text explains that the code is supposed to add up the elements of a linked list, yet for all 3 versions of the code (including the "correct code" version), the sum is only assigned to the value in each individual node, not adding up all the values.

I fixed the code by changing
`sum = p->data;`
to
`sum += p->data;`
for all 3 versions.

(This wasn't even the error that the example was trying to showcase! I was very confused when I first read through it.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant