title: Execution direction of && Condition
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5683026/logical-comparisons-is-left-to-right-evaluation-guaranteed">Logical comparisons: Is left-to-right evaluation guaranteed?</a>  </p>
  </blockquote>
  
  
  
  <p>I have been taught that for every C function arguments, Rightmost argument will be executed/processed first and it progresses towards left.
  Right part will be executed first and it progresses towards left.</p>
  
  <p>Is this applicable to conditions like &amp;&amp; and || ??</p>
  
  <p>If I am writing a C++ Code, I check for NULL condtion first and then in next if I perform my action. for e.g.</p>
  
  <pre><code> if( CommDevice != NULL)
     {
        if(CommDevice-&gt;isOpen == TRUE)
           { 
                  //Do Something
           }
  
     }
  </code></pre>
  
  <p>Can I convert this in <code>if((CommDevice != NULL) &amp;&amp; (CommDevice-&gt;isOpen == TRUE) )</code> </p>
  
  <p>That "Code executes from Right to Left" fear is stopping me coz what if <code>CommDevice</code> is NULL and I am trying to access a member of NULL.  It will generate exception.</p>