此代码不可编译:
LPSTR a1 = "a1";
LPSTR lpResult = a1 + "a2";
如何获得指向“a1a2”字符串的长指针lpResult ?
一种选择是使用 std::string 连接。您还可以使用 Microsoft 的StringCchCat函数。
这是一个例子:
#include <Strsafe.h>
//... later in your code:
LPSTR a1 = "a1";
LPSTR a2 = "a2";
TCHAR dest[ 5 ];
StringCchCopy(dest, 5, a1); // copy "a1" into the buffer
StringCchCat(dest, 5, a2); // concatenate "a2" into the buffer