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

不问归期 提交于 2019-11-27 15:30:45

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

Yes, in C++ short circuit and and or operators are available.

Here's a question answered in the C-faq on the subject.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!