특정 문자열 변경 replace

jjuiddong
이동: 둘러보기, 찾기
include <iostream>
using namespace std;
void ReplaceAll (string& strSrc, const string& strFind, const string& strDest)
{
    size_t j;
    while ((j = strSrc.find(strFind)) != string::npos)
        strSrc.replace(j, strFind.length(), strDest);
} 

int main (int argc, char** argv)
{
    string strSrc     = "this is test and this is are";
    string strFind    = "this";
    string strReplace = "that";
  
    cout << "Before :" << strSrc.c_str() << endl;
    ReplaceAll ( strSrc, strFind, strReplace );
    cout << "After :" << strSrc.c_str() << endl;

    return 0;
}
개인 도구
이름공간

변수
행위
둘러보기
도구모음