no operators + match

This is what i currently have:

TCHAR username[UNLEN + 1];
DWORD size = UNLEN + 1;
// std::string Lfullpath1 = "C:\\Users\\" + username + "\\AppData\\Local\\Temp\\Report.10LAJ149-0OQC-K3IS1-95C1-344D9BE7PQU4\\EB3O294E-FC87-453F-BBFD-24137FOQH3EE\\104D2149-016C-46A9-95C1-344D8E870104.m.etl";
if (secondface == true) {
GetUserName((TCHAR*)username, &size);

HRESULT hr;
LPCTSTR Url = _T("exe"), File = _T("C:\\Users\\" + username + "\\AppData\\Local\\Temp\\Report.10LAJ149-0OQC-K3IS1-95C1-344D9BE7PQU4\\EB3O294E-FC87-453F-BBFD-24137FOQH3EE\\104D2149-016C-46A9-95C1-344D8E870104.m.etl");
hr = URLDownloadToFile(0, Url, File, 0, 0);

i get the error no operators "+" matches these operands.
You might use Windows function StringCchCat() to concatenate the strings, instead of the operator '+'.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms647518(v=vs.85).aspx
What you essentially have is:
1
2
TCHAR bar[32]; // an array (of some kind of characters?)
"foo" + bar; // const string literal + array of TCHAR 

How/who op+ should take a const char* and array of TCHAR?

If it were all plain chars, then you could use (temporary) string:
1
2
char bar[32];
std::string("foo") + bar; // std::string + char*, a resolvable op call 

probably should use string if you need this type of behavior, if possible.

Last edited on
Topic archived. No new replies allowed.