题目描述:
假定输入的字符串中只包含字母和*号。请编写函数fun,它的功能是:删除字符串中所有*号。在编写函数时,不得使用C语言提供的字符串函数。
#include<stdio.h>
int fun(char* s);
int main()
{
char a[25] = "like**du*not*kn*o*w*";
printf("总共删除%d个*\n", fun(a));
puts(a);
}
int fun(char* s)
{
int count = 0;
char* t = s;
while (*t)
{
if (*t != '*')
{
*s = *t;
s++;
}
else
count++;
t++;
}
*s = '\0';
return count;
}
/*此段代码的调试环境为VS2019*/