删除连续出现的相同字符,哪出错了啊?
#include <stdio.h>#include <string.h>
int reduce (char s[])
{
char *scopy;
int len=strlen(s),flag=0,count=0,totalcount;
for(int i=0;i<len-1;)
{
if(s[i]!=s[i+1]) *scopy++=*s;
i++;
}
*scopy='\0';
strcpy(s,scopy);
return len-strlen(scopy);
}
void main()
{
char ss[]={"Press***12225"};
int r=reduce(ss);
printf("%d",r);
}