2 ms·
As others have pointed out, || is short circuit. I'm chiming in not to pile on, but to point out this is a canonical code pattern in C and C++. Check the point
by RogerL 12y ago
As others have pointed out, || is short circuit.
I'm chiming in not to pile on, but to point out this is a canonical code pattern in C and C++. Check the pointer, then deference it, all in the same if expression.
if (ptr && ptr->foo...
or
if (!ptr || !ptr->foo...