#include
void fun(char *a,char *h,char *p)
{
a=h;
while ( h<=p ) { if ( *h!='*' ) { *a=*h; a++; } h++; }
while ( *h ) { *a=*h; a++; h++; }
*a=0;
}
void main()
{
char s[81],*t, *f;
printf("Enter a string:\n"); gets(s);
t=f=s;
while ( *t ) t++; t--;
while ( *t=='*' ) t--;
while ( *f=='*' ) f++;
fun(s,f,t );
printf("The string after deleted:\n"); puts(s);
}
输出结果为 5
因为循环条件为 i<5,也就是循环结束时i=5
要点:不要被循环体内那个 switch-case语句迷惑了
这题不会。。。。