C++: How does one replace all instances of a character in a string with another character?
<p>I found this method on the internet: </p>

<pre><code>//the call to the method: 
cout &lt;&lt; convert_binary_to_FANN_array("1001");

//the method in question: 
string convert_binary_to_FANN_array(string binary_string)
{
string result = binary_string;

replace(result.begin(), result.end(), "a", "b ");
replace(result.begin(), result.end(), "d", "c ");
return result;
}
</code></pre>

<p>But this gives </p>

<pre><code>main.cpp:30: error: no matching function for call to ‘replace(__gnu_cxx::__normal_iterator&lt;char*, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, __gnu_cxx::__normal_iterator&lt;char*, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, const char [2], const char [3])’
</code></pre>
