title: memcmp to compare segments of an array (remove duplicates)
body: <p>I've been working on this for a while (in C) and can't figure it out.  I have a buffer containing an array of chars.  I've used qsort to sort through the array and it's all in proper order now.  I now need to remove duplicates (or just print out the list without duplicates).
  There's a caveat: the chars are grouped into groups of N chars (the N given by the user).  So it's not just comparing one char next to the other; it's comparing groups of them against each other.</p>
  
  <p>So for example: if the input is AADDBBEECCEE and the N given by the user is 2, the result would be AABBCCDDEE (with one of the EE's removed).</p>
  
  <p>I know I have to use memcmp, but I'm confused about the syntax.  I'm trying:</p>
  
  <pre><code>i=0;
  int result;
  int k;
  while(i&lt;bufferSize-nValue){
      result = memcmp(buffer[i], buffer[i+nValue], nValue);
      if(result==0){
         i=i+nValue;
      }
      else{
         for(k=0; k&lt;nValue; k++){
            printf("%c",buffer[i]);
            i++;
          }
       }
   }
  </code></pre>
  
  <p>where buffer is the array, nValue is  N, bufferSize is total number of elements in array.
  I keep getting segmentation fault when running the code.</p>
  
  <p>Thanks for your help, everyone!</p>