函数连接两个写入此缓冲区开头的字符串?

时间:2012-09-11 13:27:17

标签: c++ concatenation

我们在Win32Api中有StringCchCat函数,

  

将一个字符串连接到另一个字符串。目的地的大小   缓冲区提供给函数以确保StringCchCat的功能   不写在这个缓冲区的末尾。

好的..

StringCchCat(dirWPath, MAX_PATH, TEXT("\\*"));

我会得到:dirWPath +" \\ *"

我希望得到一个:" \\ *" + dirWPath

任何人都有解决方案吗?

2 个答案:

答案 0 :(得分:1)

std::string first = dirWPath, second = "\\*";
std::string result = second + first;

答案 1 :(得分:0)

您可以先传递通配符:

char str1[MAX_PATH] = "\\*";
StringCchCat(str1, MAX_PATH, dirWPath);