Link to home
Start Free TrialLog in
Avatar of DougC
DougC

asked on

Simple String Concat Question

LPCTSTR m_pszExeName; // I have this, its the exe name

char buf[128]; // I want to add this onto it it has a name in it
------------------

I want to concat a char buffer(up to 128 bytes) onto an LPCTSTR. What is the easiest way? The end reslt needs to be a concatanated LPCTSTR to use for CreateSeamphore.

HANDLE hSem = CreateSemaphore(NULL, 1, 1, MyConcatLPCTSTRgoesHere);


Thanks for the help,
Doug
ASKER CERTIFIED SOLUTION
Avatar of vadik
vadik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gj62
gj62

vadik -

Just a quick note - the order of your strings I think is backward.  

Buf would actually equal "SecondStrFirstStr" after concatenation.

I think he wants _tcscat(lp, buf);
Just I thought that it's not good to change LPCTSTR because this is pointer to const. But this is only my oppinion.
Just I thought that it's not good to change LPCTSTR because this is pointer to const. But this is only my oppinion.
You are right, though MSFT shows examples of doing exactly that - anyhow, he'd be better off creating a new object and storing the concatenated string there...

e.g.

CString params;
params = lp + buf;

would probably be easiest...
If you are using MFC :)
True - bad assumption...