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

删除string里面的指定字符

时间:2014-05-22 16:57:45      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:style   class   c   code   ext   color   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    string    str("abcdefg");
    string::iterator   it;
 
    for (it =str.begin(); it != str.end(); ++it)
    {
        if ( *it == ‘c‘)
        {
            str.erase(it);
        }
    }
 
    cout << str << endl;
}

删除string里面的指定字符,布布扣,bubuko.com

删除string里面的指定字符

标签:style   class   c   code   ext   color   

原文地址:http://blog.csdn.net/u013340181/article/details/26579585

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