Bug in Programming Interviews Exposed?
Posted
by
Sam
on Stack Overflow
See other posts from Stack Overflow
or by Sam
Published on 2011-03-01T06:56:28Z
Indexed on
2011/03/01
7:25 UTC
Read the original article
Hit count: 222
c
|interview-questions
Hi,
I could not find an errata for the 2nd edition of this book. My question concerns the if-statement in the following piece of code.
void removeHead (Node ** head) {
Node * temp;
if (!(*head)) {
temp = (*head)->next;
delete *head;
*head = temp;
}
}
So I understand that the point of the if-statement is to check if the Node is null. However by adding an additional "!" to the evaluation, wouldn't this negate the false value of null? Would it be correct to change it to something like:
if (*head) { ... }
Also if anyone knows where I can find an official errata for the 2nd edition that would be great.
Thanks,
Sam
© Stack Overflow or respective owner