title: C - Logical AND operands not swapable in this case?
body: <p>I am learning linked lists in C, and I came across an error I don't understand.  In the snippet of code I have pasted below, when I have while(a &amp;&amp; b), I get an infinite loop, but when I run while(b &amp;&amp; a), the program works.  I am new to C and don't understand why I get the infinite loop in the first case.</p>
  
  <p>This gives me an infinite loop:</p>
  
  <pre><code>while((*searchNodePtr).data != dataValue &amp;&amp; searchNodePtr != NULL) {
      prevNodePtr = searchNodePtr;
      searchNodePtr = (*searchNodePtr).next;  
  }
  </code></pre>
  
  <p>But this works (swapped while condition operands):</p>
  
  <pre><code>while(searchNodePtr != NULL &amp;&amp; (*searchNodePtr).data != dataValue) {
      prevNodePtr = searchNodePtr;
      searchNodePtr = (*searchNodePtr).next;  
  }
  </code></pre>
  
  <p>Any clarification would be much appreciated.  Thank you.</p>