删除字符串中的指定字符

 1 #include<stdio.h> 2  3 /** 删除字符串中的指定字符 4  */ 5 #define LEN 50 6  7 char * del_ch(char s[], char c);  8  9 int main(){10     char str[] = "xyzxxguo";11     char ch = 'x';12     char *p;13     printf("before delete ch: %s\n", str);14     p = del_ch(str, ch);15     printf("after delete ch: %s", p);16 }17 18 char * del_ch(char s[], char c){19     static char new_str[LEN];20     int i = 0,j = 0;21     while(s[i] != '\0'){22         if(s[i] != c){23             new_str[j++] = s[i];24         }25         i++;26     }27     new_str[j] = '\0';28     return new_str;29 }

往往教导我们大家要好好学习天天向上,要永不言弃坚持到底百折不挠宁死不屈,

删除字符串中的指定字符

相关文章:

你感兴趣的文章:

标签云: