Concatenating the strings in the char array in c ++ (using less strcat)


For example, I have a code like this.

    char NameTmp[] = "foo.txt";
    char Name[] = "bar.txt"
    char cmd[80] = "./analyzeText ";
    strcat(cmd, Name);
    strcat(cmd, " ");
    strcat(cmd, NameTmp);
    strcat(cmd, " ");
    strcat(cmd, "8");

Basically, I am trying to call "./analyzeText bar.txt foo.txt 8" on linux on my program. analyzeText is program already made and is in the same folder.

I'm wondering is there a shorter way than to use "strcat" to make strings in c++?

Use some strings:

std::string NameTmp = "foo.txt";
std::string Name = "bar.txt";
std::string cmd = "./analyzeText " + Name + " " + NameTemp + " 8";

It's slightly less efficient (more strings are created), but it's much simpler.