Home >Backend Development >C#.Net Tutorial >c language to delete numeric characters in string
目的:
C语言实现删除字符串s中的数字字符。
具体代码如下:
// 删除数字 #include <stdio.h> #define N 100 int main(void) { char s[N]; int j,k; gets(s);// 输入字符串 for(j = k = 0;s[j]!='\0';j++)// 此循环用于删除字符串中的数字 if(s[j]<'0'||s[j]>'9') s[k++] = s[j]; s[k] = '\0';// 处理过的字符串加上结束标志'\0' puts(s);// 输出处理过的字符串 return 0; }
输出结果:
推荐教程:c语言教程
The above is the detailed content of c language to delete numeric characters in string. For more information, please follow other related articles on the PHP Chinese website!