Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions _topics/antipatterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ symptom that shows this code is wrong?
sum += p->data;
while (p->next != NULL) {
p = p-> next;
sum = p->data;
sum += p->data;
}
return sum;
}
Expand All @@ -299,7 +299,7 @@ the symptom that shows this code is wrong?
sum += p->data;
while (p != NULL) {
p = p-> next;
sum = p->data;
sum += p->data;
}
return sum;
}
Expand All @@ -312,14 +312,14 @@ The correct code is this:
int sum=0;
Node *p=head;
while (p != NULL) {
sum = p->data;
sum += p->data;
p = p-> next;
}
return sum;
}
```

Which can be expresssed more succinetly with a for loop. Using a for
Which can be expressed more succinctly with a for loop. Using a for
loop is less error prone, since everything is more likely to end up
where it should:

Expand Down