Anybody can help to explain why "m_line.replace(idx, m_search.size(), replace);" doesn't compile in cygwin and how to change it?
Thanks.
using namespace std;
int main(int argc, char *argv[])
{
assert(argc==3 &&
"Usage: <searchstring> replacestring> to process stdin");
string m_line;
string m_search(argv[1]);
string m_replace(argv[2]);
assert(m_search!=m_replace);
while(getline(cin, m_line)) {
while(true) {
string::size_type idx = m_line.find(m_search);
if(idx == string::npos) break;
m_line.replace(idx, m_search.size(), replace);
}
cout << m_line << endl;
}
system("PAUSE");
return 0;
}
<< moderator edit: fixed [code][/code] tags >>