字符串中删除数字

 1 #include<string.h>
 2 #define MAX 100
 3 #include<iostream>
 4 using namespace std;
 5 int main()
 6 {
 7     printf("在西安的古道,写着庸俗的代码\n");
 8     
 9     char  str[MAX];
10     int count = 0;
11     cin.getline(str,MAX);
12     int len = strlen(str);
13     char temp[MAX];
14     for (int i = 0; i<len; i++)
15     {
16         if (str[i]<'0'||str[i]>'9')
17         {
18             temp[count++] = str[i];
19         }
20     }
21     temp[count] = '\0';
22     strcpy_s(str, temp);
23     printf("%s",str);
24     return 0;
25     
26 }

 

posted @ 2017-12-02 15:26  当年和风  阅读(999)  评论(0编辑  收藏  举报