C语言 编写函数fun

来源:百度知道 编辑:UC知道 时间:2024/06/13 23:31:30
该函数的功能是:假定输入的字符串只包含字母和*,将字符串尾部的*全删除,前面和中间的*却不删除
在线急等

#include <stdio.h>
#include <string.h>
void fun(char b[])
{char *p,*q;
int i=0;
printf("before:\n%s\n",b);
p=b;
q=b;
while(*p)
{
if(*p>='A'&&*p<='Z'||*p>='a'&&*p<='z')
q=p;
p++;
}
q++;
*q='\0';
printf("after sort:\n%s\n",b);
}
main(void)
{
char a[20]={"***a**aASab*bd*****"};
fun(a);
}

#inlude<stdio.h>

void fun(char* p)
{
while( p[strlen(p)-1] =='*')
p[strlen(p)-1] = 0;
}

///////////////////////////下面是测试程序
int main()
{
char a[]="***1**31***22*342*******";
fun(a);
printf("%s",a);
return 0;
}

#include<stdio.h>

void fun(char* p)
{
int i=0,count=0;
while(p[i])
{