C : is there “lazy evaluation” when using && operator, as in C++?

前端 未结 4 1549
后悔当初
后悔当初 2020-12-03 21:20

I would like to know if this looks correct :

while((next !=NULL) && (strcmp(next->name, some_string) < 0) {
    //some process
}
4条回答
  •  执笔经年
    2020-12-03 21:50

    Yes && is short circuited and you are using it correctly.
    If next is NULL string compare will never happen.

提交回复
热议问题