if with multiple conditions, order of execution

Posted by markus on Stack Overflow See other posts from Stack Overflow or by markus
Published on 2010-03-16T16:19:15Z Indexed on 2010/03/16 16:21 UTC
Read the original article Hit count: 169

Filed under:

Hi,

In an if statement with multiple conditions is second executed if the outcome is clear after checking the first condition?

example:

if(i>0 && array[i]==0){
}

If I swap the conditions a seg fault may occur for negative values of i but this way the memory debugger doesn't find a problem. Can I be sure that this works always or do have have to use nested if statements?

© Stack Overflow or respective owner

Related posts about c