删除连续出现的相同字符,没有错误,结果却不对。。请问为什么啊?
#include <stdio.h>#include <string.h>
#include <stdlib.h>
int reduce (char s[])
{
int len=strlen(s);
char *scopy;
scopy=(char *)malloc((len+1)*sizeof(char));
while(*(s+1)!='\0')
{
if(*s!=*(s+1))
*scopy++=*s;
s++;
}
strcpy(s,scopy);
return len-strlen(scopy);
}
void main()
{
char ss[]={"Press***12225"};
int r;
r=reduce(ss);
printf("%d\n",r);
}