麻烦帮忙看看这个代码,debug好像在*s2='*';有问题

//删除特定位置的字符**,比如输入******AA*AA***S*,要求输出******AAAAS
#include
#include
void fun(char*);
int main()
{
char *s1;
s1=(char *)malloc(30);
printf("输入字符串(小于30个字符):");
gets(s1);
fun(s1);
return 0;
}
void fun(char *s1)
{
char *s2,*reset=s1;
s2=(char *)malloc(30);
int i=0,num=0;

while(*s1++=='*')
{
    num++;
}
for(i=0;i<num;i++,s2++)
{
    *s2='*';
}
while(*s1!='\0')
{
    if(*s1!='*')
    {
        *s2++=*s1++;
    }
    else
    {
        s1++;
    }
}
*s2='\0';
printf("%s",s2);

}

这种程序很多都是代码指针问题,具体的调试就知道了。

*s2='\0'; //指向要输出字符串的结束字符,所以输出错误