Passing char arrays to a function - best practice

If I pass a character array to a function, then add to it by using strcat() will my program adjust the memory allocated for this char array, or am I going to run into a memory problem. For example

void createMsg() {
  char msgTweet[27];
  strcpy(msgTweet, "This is 26 characters long");
  sendMsg(msgTweet);
}

void sendMsg(char msgToSend[]){
  char addToMsg[] = "stuff";

  // add stuff to the message
  strcat(msgToSend, addToMsg);
  Serial.println(msgToSend);
}
1 Like