I would like to know if this looks correct :
while((next !=NULL) && (strcmp(next->name, some_string) < 0) {
//some process
}
Yes, in C++ short circuit and
and or
operators are available.
Here's a question answered in the C-faq on the subject.
Yes &&
is short circuited and you are using it correctly.
If next
is NULL
string compare will never happen.
It's definitely the case in both C and C++.
This will work with lazy evaluation (the second statement not evaluated if the first one is evaluated to "false") unless your compiler is so non-standard compliant it can't even be named a C compiler. Millions lines of code in the field rely on this behavior, so you can think that this behavior is just guaranted.