title: iterating through a struct in c
body: <p>I am writing a Unit Test that is similar to this code, and I am trying to test my values as I set them, so that I know what is going on. I don't understand why the ptr values are not being set to 1, when I run the following code. Instead when I run this it gives me an output of 10, 64, 0, 0.</p>
  
  <p>Any explanation or advise would be greatly appreciated!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdbool.h&gt;
  
  typedef struct
  {
      bool bOne;
      bool bTwo;
      bool bThree;
      bool bFour;
  } items;
  
  int main()
  {
      items item;
      item.bOne = 0;
      bool *ptr = &amp;(item.bOne);
  
      for(int i = 0; i &lt; sizeof(items)/sizeof(bool); i++)
      {
          *ptr = 1;
          *ptr++;
          printf("ptr value = %d\n", *ptr);
      }
      return 0;
  }
  </code></pre>