title: C remove duplicate char from array
body: <p>Somewhere in my program I get these outputs:</p>
  
  <pre><code>ee
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>thht
  </code></pre>
  
  <p>Basically I want to remove the duplicates to obtain <code>e</code> or <code>th</code>. I got this code:</p>
  
  <pre><code>j = 0;
  for (i = 1; i &lt; strlen(erros); i++)
  {
      if (erros[j] != erros[i])
      {
          erros[j+1] = erros[i];
          j++;
      }
  }
  </code></pre>
  
  <p>This code gives me <code>e</code> and <code>tht</code>. If in the first case its OK, in the second its not. I believe it is due because I don't have a sorted array.</p>
  
  <p>Is there a way, without sorting the array and using the above code, to obtain the desired output?</p>