[code lang=”c”]
#include <stdio.h>
void str_rem_dup(char *desc,const char src)
{
char *p = desc;
while(*p)
{
if(*p == src){
break;
}
p++;
}
printf("%s\n",desc);
char *p2 = p;
while(*p2++)
{
if(*p2 != src)
{
*p++ = *p2;
}
}
*p2 = 0;
}
int main()
{
char a[] = "sdfasdljflsdkfjlaskjddfd";
printf("%s\n",a);
str_rem_dup(a,’d’);
printf("%s\n",a);
return 0;
}
[/code]
str_rem_dup 删除重复字符