假定输入的字符串中只包含字母和*号。请编写函数fun,其功能是:除了尾部的*号之外,将字符中其他的*号全部删除。形参P已指向字符串中最后的一个字母。在编写函数时,不得使用C语言提供的字符串函数。
例如,字符串中的内容为“****A*B*DEF*
G********”,删除后,字符串中的内容应当是“ABCDEFG*******”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#incIude<conio.h>
#include<sfdio.h>
void fun(char*a,char*P)
void 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);