码迷,mamicode.com
首页 > 其他好文 > 详细

字符串中删除数字

时间:2017-12-02 16:11:25      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:stream   count   line   mes   代码   span   for   printf   getline   

 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 }

 

字符串中删除数字

标签:stream   count   line   mes   代码   span   for   printf   getline   

原文地址:http://www.cnblogs.com/dangnianhefeng/p/7954365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!