user53592: Task: delete "\n" at the beginning of the array.
Example:
char s_msg[15] = "\nHello world!";

void setup()
{
  Serial.begin(115200);
  Serial.println("Load");
  // Search \n
  if(strstr(s_msg, "\n") != NULL) {
    Serial.println(s_msg);
    strlcpy(s_msg, &s_msg[1], sizeof(s_msg));
    Serial.println(s_msg);
  }
}

void loop() {}

Description:
If the \ n character is present at the beginning of the message, then we copy the original character to the same character, but without \ n.
Question: is it ok to copy char to itself (s_msg is the destination buffer and the source string at the same time)

user7508: This manual page of strlcpy() is quite clear:

If the src and dst strings overlap, the behavior is undefined.

This means you should avoid it, even if it works on some tests. The
advice you got of just trying is not good advice. Use
memmove() instead.

53592: <p><strong>Task:</strong> delete "\n" at the beginning of the array.</p>

<p><strong>Example:</strong></p>

<pre><code>char s_msg[15] = "\nHello world!";

void setup()
{
  Serial.begin(115200);
  Serial.println("Load");
  // Search \n
  if(strstr(s_msg, "\n") != NULL) {
    Serial.println(s_msg);
    strlcpy(s_msg, &amp;s_msg[1], sizeof(s_msg));
    Serial.println(s_msg);
  }
}

void loop() {}
</code></pre>

<p><strong>Description:</strong>
If the \ n character is present at the beginning of the message, then we copy the original character to the same character, but without \ n.</p>

<p><strong>Question:</strong> is it ok to copy char to itself (s_msg is the destination buffer and the source string at the same time)</p>
 7508: <p>This <a href="https://www.freebsd.org/cgi/man.cgi?query=strlcpy&amp;sektion=3" rel="noreferrer">manual page of <code>strlcpy()</code></a> is quite clear:</p>

<blockquote>
  <p>If the <code>src</code> and <code>dst</code> strings overlap, the behavior is undefined.</p>
</blockquote>

<p>This means you should avoid it, even if it works on some tests. The
advice you got of just trying is <em>not</em> good advice. Use
<a href="https://www.freebsd.org/cgi/man.cgi?query=memmove&amp;sektion=3" rel="noreferrer"><code>memmove()</code></a> instead.</p>
