C/C++ on Arduino string .replace() function is not working
<p>I have this method in Arduino which has its programming language based on C/C++ and it is supposed to replace \r and \n so that it prints \r and \n as it is, but when I try to run the code it gives an no match for operator error: </p>

<pre><code>void debugmsg(String msgtext) {
  msgtext = msgtext.replace("\r","\\r");
  msgtext = msgtext.replace("\n","\\n");
  Serial.println(msgtext1 + "\r\n");
}
</code></pre>

<blockquote>
  <p>no match for 'operator=' (operand types are 'String' and 'void')</p>
</blockquote>

<p>i dont know what's wrong, thank you for helping!</p>