为啥输不出来结果来
这个小程序就是去除连续相同字符 就是输不出结果来
#include <iostream.h>
char * delsame(char *str)
{
int k=0;char temp[10];
for(char *p=str;p!='\0';p++)
{
if(k==0) temp[k++]=*p;
else if(temp[k-1]!=*p) temp[k++]=*p;
}
temp[k]='\0';
for(int i=0;i<=k;i++)
str[i]=temp[i];
return str;
}
void main()
{
char a[10]="abcddef";
cout<<delsame(a);
}