我知道我可以用它们构造字符串并简单地使用 operator+。 但是我需要将连接的 char 数组传递给旧的 C 函数,所以我不能这样做。
最佳答案
您可以使用
std::string
std::string s1 = "Hello", s2 = "World"; std::string s3 = s1 + s2; const char* c_data = s3.c_str( ); // pointer to char array
您可以使用 strcat 来完成功能
关于c++ - 有没有直接的方法来连接两个字符数组 (char*)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28124031/