字符串中字符的删除

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 char *fun(char *s,char c)
 5 {
 6       char *p=s;   //用指针p指向字符串s的首地址
 7       char *pp=p;  //pp指向字符串p的首地址
 8       for(;*s != '';s++)    //如果指向的当前字符串不是‘’
 9       {
10               if(*s != c)       //如果当前字符串不等于指定字符
11               {
12                    *p++ = *s;     //将当前字符写入指针p
13                  }
14        }
15        *p = '’      //字符串末尾增加字符串结束标志16        return pp;     //返回所得字符串
17 }
18 
19 int main()
20 {
21     char s[20] = "Hello world!";
22     printf("%s
",s);
23     char *ppr;
24     ppr=fun(s,'l');
25     printf("%s
",ppr);
26     return 0;
27 }
原文地址:https://www.cnblogs.com/wangmengmeng/p/4619679.html