PubSubClient - Programmatically set topic/payload string

I'm playing with the PubSubClient library on an ESP8266. So far for every time I publish or subscribe, I'm using hard-coded topic strings. mqttClient.subscribe("test/relay/enable/cmd"); I would like to programmatically set the topic string using two or three other strings but the only way I can figure out is something like the following.

void sendMqttConnectedMsg(){
  msgString.concat(WiFi.SSID());
  msgString.concat("\r\n");
  msgString.concat(WiFi.macAddress().substring(9));
  msgString.concat("\r\n");
  String runTime = timeToString(millis() / 1000);
  msgString.concat(runTime);
  char msgChar[msgString.length()+1]; // +1 for NUL terminator
  msgString.toCharArray(msgChar, msgString.length()+1); // same as above, add +1
  mqttClient.publish("test/relay/msg", msgChar, 1);
}

char * timeToString(unsigned long _t){ // t is time in seconds = millis()/1000;
 static char str[15];
 int d = _t / 86400;
 _t = _t % 86400;
 int h = _t / 3600;
 _t = _t % 3600;
 int m = _t / 60;
 int s = _t % 60;
 sprintf(str, "%04d:%02d:%02d:%02d", d, h, m, s);
 return str;
}

What are some other techniques where I can create a universal function which takes my 2 or 3 strings as parameters and returns/outputs something PubSubClient can use? Most of my reason for wanting to do this so that I can set a couple strings at the beginning of my program to customize it instead of changing all the instances throughout the code.

What are some other techniques where I can create a universal function which takes my 2 or 3 strings as parameters and returns/outputs something PubSubClient can use?

strcpy() and strcat() with strings are far better than pissing away resources on the String class.

PaulS: strcpy() and strcat() with strings are far better than pissing away resources on the String class.

How would this code look using only strings instead of Strings?

void sendMqttConnectedMsg(){
  msgString.concat(WiFi.SSID());
  msgString.concat("\r\n");
  msgString.concat(WiFi.macAddress().substring(9));
  msgString.concat("\r\n");
  String runTime = timeToString(millis() / 1000);
  msgString.concat(runTime);
  char msgChar[msgString.length()+1]; // +1 for NUL terminator
  msgString.toCharArray(msgChar, msgString.length()+1); // same as above, add +1
  mqttClient.publish("test/relay/msg", msgChar, 1);
}