编写函数fun,其功能是:将字符串头部和尾部的*号全部删除,中间的*号不动。规定输入的字符串只包含

编写函数fun,其功能是:将字符串头部和尾部的*号全部删除,中间的*号不动。规定输入的字符串只包含字母和*号
急,在线等,谢谢

第1个回答  2015-12-27
#include <stdio.h>
#include <string.h>
void fun(char *a)
{
int i = 0,j;
int m,n;
while(a[i] == '*')
i++;
for(m = 0; m <strlen(a); m++,i++)
{
a[m] = a[i];
}
a[m] = '\0';
j = strlen(a)-1;
while(a[j] == '*')
j--;
a[j+1] = '\0';
}

int main(void)
{
char a[80];
gets(a);
fun(a);
puts(a);
}追问

谢谢!!!!

本回答被提问者采纳
相似回答