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

Function to concatenate two string who write to the begin of this buffer?

本文关键字:缓冲区 开头 字符串 两个 连接 函数      更新时间:2023-10-16

我们在Win32Api、中有StringCchCat函数

将一个字符串连接到另一个字符串。目的地的大小为函数提供缓冲区,以确保StringCchCat不要写超过这个缓冲区的末尾。

好吧。。

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

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

我想得到一个:"\\*"+dirWPath

有人有解决方案吗?

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

您可以先传递通配符:

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