title: how to remove duplicate from a string in c?
body: <p>Following is the C code I tried for removing duplicate character in a string, but it is not running properly, it get stuck at comment <em>stuck</em>. Please help me to understand what I am doing wrong?</p>
  
  <pre><code>void removeDupliacte(char *str)
  {
      int bitset=0;
      int value= 0;
      char *tail = str;
      char temp;
      int i=0;
      while(*str)
      {
          value = *str - 'a';
          if(bitset &amp; (1 &lt;&lt; value) &gt; 0 )
          {
              str++;
          }
          else
          {
              bitset |= 1 &lt;&lt; value;
              temp = *str;
              tail[i] =temp; /*stuck*/
              i++;
              str++;
          }
      }
  tail[i++] = '\0';
  
  }
  
  int main()
  {
      char *str = "abac";
      removeDupliacte(str);
      printf("%s",str);
      return 0;
  }
  </code></pre>