title: C: How do you count items in a struct?
body: <p>So I have a structure of unknown size as follows:</p>
  
  <pre><code>typedef struct a{
  int id;
  char *name;
  enum job {builder=0, banker, baker};
  } person;
  
  person p;
  </code></pre>
  
  <p>and I want to count how many entries are in the struct through some sort of loop.  I'm sure this is very simple and I'm just not thinking about it correctly but I can't seem to figure out how I would this without knowing its size.</p>
  
  <p>So presumably I can't use:</p>
  
  <pre><code>for(i=0; i&lt;x; i++) //where x is the size of the struct
  {
     if(p.id!=0)
        count++;
  }
  </code></pre>
  
  <p>what am i missing here?</p>