title: why memcmp returns -1 although equal
body: <p>I'm comparing using <code>memcmp()</code> two variables of the same struct (the struct has union in it).
  The variables are in two arrays and I'm running a loop where each iteration I do <code>memcmp(&amp;arr1[i], &amp;arr2[i], sizeof(arrtype))</code>.</p>
  
  <p>When debugging I see that memcmp returns -1, but looking at the two variables and their values, I see that the variables has equal values. These arrays are zeroed with memset at the beginning.</p>
  
  <ol>
  <li>So does anybody know why <code>memcmp</code> returns -1 and not 0?</li>
  <li>Is there a better way to do what I need (compare two memory blocks)?</li>
  </ol>
  
  <p>code:</p>
  
  <pre><code>typedef struct type1 {
      int version;
      union {
              option1_t opt1;
              option2_t opt2;
      } union_t;
  } type1_t;
  
  typedef struct type0 {
      type1_t member1;
      type2_t member2;
      type3_t member3;
      type4_t member4;
      type5_t member;
  } type0_t;
  
  
  type0_t arr1[SIZE];
  type0_t arr2[SIZE];
  
  memset(arr1, 0, SIZE * sizeof(type0_t));
  memset(arr2, 0, SIZE * sizeof(type0_t));
  
  /* doing irrelevant stuff... */
  
  /* get values into arr1, arr2 ... */
  
  
  /* comparing both arrays in for loop*/
  value = memcmp(&amp;arr1[i], &amp;arr2[i], sizeof(type0_t));
  </code></pre>