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 stuck. Please help me to understand what I am doing wrong?
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 & (1 << value) > 0 )
{
str++;
}
else
{
bitset |= 1 << value;
temp = *str;
tail[i] =temp; /*stuck*/
i++;
str++;
}
}
tail[i++] = '\0';
}
int main()
{
char *str = "abac";
removeDupliacte(str);
printf("%s",str);
return 0;
}