|
|
|
|
|
by hadcomplained
2024 days ago
|
|
The following is the code I wrote before reading the example pieces of code. void remove(IntList* l, IntListItem* target) {
if (l->head == target) {
l->head = l->head->next;
return;
}
IntListItem* prev = l->head;
while (prev->next != target) prev = prev->next;
prev->next = prev->next->next;
}
Skimming the comments here, I was surprised not to see an equivalent piece of code mentioned. To me my code is more readable than both of the first and second examples presented in the article. Does that mean my taste is peculiar? |
|
I'd say C syntax for double pointers is a lot less kind than the syntax for single pointers. Your version thankfully lacks any line like so, without making me think about parens