此代码无法编译:
LPSTR a1 = "a1";
LPSTR lpResult = a1 + "a2";
如何在" a1a2"中找到一个长指针 lpResult ;字符串?
答案 0 :(得分:2)
一种选择是使用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