0

I'm having a hard time understanding why my code isn't working. I've spend days breaking my head over this. I'm hoping someone can help me understand what I'm doing wrong.

I'm trying to append one string (LPCTSTR) to another (LPTSTR) using StringCchCat.

//LPTSTR tempPath = _T(""); 
LPTSTR tempPath = new TCHAR[MAX_PATH];
LPCTSTR src = _T("Text to append");
StringCchCat(tempPath, MAX_PATH, src);
std::wcout << tempPath << std::endl;    

However, the src string does not get appended to the destination. On printing, it prints a blank line.

I'm looked around to see if I am initializing the tempPath variable correctly and based on other stackoverflow threads it seems to be fine. I initially tried initializing it using the _T(), however, this gives me an 'Access Violation' error when it attempts to append the strings with StringCchCat

I'm relatively new to C++ and am unsure as to why the string isn't getting appended.

(This code is a stripped down version of a larger block of code - I do need to use StringCchCat and the string types used in the block above)

qwerty941
  • 1
  • 2

0 Answers0