Programmer Application Note

2015년 11월 18일 수요일

2015년 11월 17일 화요일

c++ string replace all

오전 12:26 Posted by PAN.SPOT , No comments
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
   cout << "Hello World" << endl;
   string str = "ab0cd0e0fg";
   replace_if(str.begin(),str.end(),bind2nd(equal_to<char>(),char('0')),char('-'));
   cout << str << endl;
   return 0;
}

output:
        ab-cd-e-fg