I am still new to STL and wanted to replace all occurrences of ch
in a string with k
.
I tried the following:
std::replace (str.begin(), str.end(), "ch", "k");
But it threw this error:
no matching function for call to ‘replace(__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >, const char [2], const char [1])
How do I get replace
to work in this case?
Note: I saw a similar question but in that case the OP was using "blah" and 'b' as arguments to be replaced but here both of my arguments are strings.