Date: Thu, 07 Aug 1997 17:46:47 +0200 From: Hans-Bernhard Broeker Subject: Re: [Q] expression evaluation order To: xfesenko AT pacific DOT net DOT sg (Victor) Cc: djgpp AT delorie DOT com Message-id: <01IM60KCNPZE8WW0BY@mail> Organization: RWTH Aachen, III. physikalisches Institut B Content-transfer-encoding: 7BIT Newsgroups: comp.os.msdos.djgpp Precedence: bulk In article <5sbb1h$kvr$1 AT newton DOT pacific DOT net DOT sg> you wrote: > Is it safe to assume that the expression > if(first_function()==OK && second_function()==OK && > third_function()==OK) return(OK); > will be evaluated from left to right? In contrast to the other answer I just had to see in the newsgroup: *Yes*, this behaviour is even guaranteed by the ANSI C Standard, and it was like that even before the Standard was written. The so called 'short-circuiting' of logical expressions is what requires the fixed order of evaluation of terms here: if first_function() did *not* return 'OK', then none of the other functions need to be called: the result of the expression is 'false' anyway. So they won't be called. HBB