title: How to calculate the number of the array elements in the struct
body: <p>I would like to calculate the number of element of the array using the following c code :</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  // Number of elements in an array
  #define NUM_ELEM(x) (sizeof((x)) / sizeof((x)[0]))
  #define LIST_KEY (char *[])
  typedef struct dm_key_reg {
      char *obj;
      char **ukey;
  }DMKEYREG;
  
  DMKEYREG tab_reg_key[]={
  {&quot;Device_SS&quot;, LIST_KEY{&quot;SerialSS&quot;, &quot;SSS&quot;, &quot;A&quot;}},
  {&quot;Device__AP&quot;, LIST_KEY{&quot;SerialAP&quot;, &quot;III&quot;, &quot;B&quot;}},
  {&quot;Device___EP&quot;, LIST_KEY{ &quot;SerialEP&quot;, &quot;EEE&quot;, &quot;CCC&quot;, &quot;C&quot;}},
  {0}
  };
  
  int main(void)
  {
      int i=0;
  DMKEYREG *tab_key = tab_reg_key;
  for (; tab_key-&gt;obj; tab_key++) {
      i++;
      printf(&quot;i=%d &lt;&gt;  ukeysize= %d\n&quot;,i, NUM_ELEM((tab_reg_key-&gt;ukey)));
  }
  }
  </code></pre>
  <p>but I got the following result:</p>
  <pre><code>i=1 &lt;&gt;  ukeysize= 1
  i=2 &lt;&gt;  ukeysize= 1
  i=3 &lt;&gt;  ukeysize= 1
  </code></pre>