title: Error checking array element to null
body: <p>This question may be a duplicate of this <a href="https://stackoverflow.com/questions/4178804/how-to-see-if-an-element-is-null-in-an-array-in-c">question</a> or this <a href="https://stackoverflow.com/questions/1793867/best-way-to-check-if-a-character-array-is-empty">question</a></p>
  
  <p>I am using C and trying to communicate with a device which works on serial communication. I am reading a single byte and storing it in an array and then checking the array element to <code>'\0'</code> (<code>0x00</code>). If it's <code>'\0'</code> then that means the data is now not available.</p>
  
  <pre><code>volatile int rxFlag = 0;
  volatile int index = 0;
  
  void function()             //event based function, whenever a byte is received
  {
    Rx[index] = ReadUSART();     //reading a byte
    if(Rx[index] == '\0' )       //checking if its null 
    {
      rxFlag = 1;                //raise a flag
  
    }
    index++;                       //increment index
  }
  </code></pre>
  
  <p>Below is the screenshot of the Rx:</p>
  
  <p><a href="https://i.stack.imgur.com/bzM64.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bzM64.png" alt="enter image description here"></a></p>
  
  <p>In the image you can see the from <code>Rx[0]-Rx[24]</code> it contains data but  <code>Rx[25]</code> is a null terminator (<code>0x00</code>) and the <code>rxFlag</code> should be set to 1. But it is not set. </p>
  
  <p>What is the another way of checking if the array element is <code>'\0'</code>.</p>