Is short-circuiting logical operators mandated? And evaluation order?

前端 未结 7 2590
广开言路
广开言路 2020-11-21 04:11

Does the ANSI standard mandate the logical operators to be short-circuited, in either C or C++?

I\'m confused for I recall the K&R book saying your code

7条回答
  •  被撕碎了的回忆
    2020-11-21 05:00

    If you trust Wikipedia:

    [&& and ||] are semantically distinct from the bit-wise operators & and | because they will never evaluate the right operand if the result can be determined from the left alone

    C (programming language)

提交回复
热议问题