특정 문자열 변경 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; }