title: length of char array in C
body: <p>I have an array like this: </p>
  
  <pre><code>char data[512];
  </code></pre>
  
  <p>for clearing my array use:</p>
  
  <pre><code>memset(&amp;data[0], 0, sizeof(data));
  </code></pre>
  
  <p>I defined:</p>
  
  <pre><code>#define NELEMS(x)  (sizeof(x) / sizeof(x[0]))
  </code></pre>
  
  <p>but when I tried to get the the number of my array, it still gives 512;</p>
  
  <pre><code>int a = NELEMS(data); 
  </code></pre>
  
  <p>I want to  clear my array, then I add some element, How can I get the number of element inside my array (element inserted)?</p>