假定输入的字符串中只包含字母和*号。请编写函数 fun(),它的功能是:除了尾部的,:号之外,将字符串
假定输入的字符串中只包含字母和*号。请编写函数 fun(),它的功能是:除了尾部的,:号之外,将字符串中其他*号全部删除。形参p已指向字符串中最后一个字母。在编写函数时,不得使用C语言的字符串函数。
例如,若字符串中的内容为****A*BC*DEF*G******,删除后,字符串中的内容应当是ABCDEFG******。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio. h>
void fun(char *a, char *p)
{
}
main ( )
char s[81],*t;
printf ("Enter a string: \n ");
gets (s);
t=s;
while (*t)
t++;
t--; /*指针t指向字符串尾部* /
while (*t== '*' )
t--; /*指针t指向最后一个字母*/
fun (s, t);
printf ("The string after deleted: \n");
puts (s);
}