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

前端 未结 7 2831
广开言路
广开言路 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:03

    Straight from good old K&R:

    C guarantees that && and || are evaluated left to right — we shall soon see cases where this matters.

提交回复
热议问题