Multiple WCHAR_T to CString

Hey guys,

I have a series of wchar_t variables and I wish to combined them and make it into a CString variable:

// Example
wchar_t x1 = 'T';
wchar_t x2 = 'e';
wchar_t x3 = 's';
wchar_t x4 = 't';

CString test;

I wish to add x1, x2, x3 and x4 into the CString "test".

Thank you in advance!
LVL 1
mr_stevieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lucky_jamesCommented:
wchar_t x1 = 'T';
wchar_t x2 = 'e';
wchar_t x3 = 's';
wchar_t x4 = 't';
CString test;

CString x1_temp = x1;
CString x2_temp = x2;
CString x3_temp = x3;
CString x4_temp = x4;
test = x1_temp + x2_temp + x3_temp + x4_temp;

0
mr_stevieAuthor Commented:
Unfortunately I get the following error:
error C2440: 'initializing' : cannot convert from 'wchar_t' to 'ATL::CStringT<BaseType,StringTraits>'      
0
lucky_jamesCommented:
Sorry, I dint try compiling before my previous reply....
Call the constructors explicitly.
      CString str_1 =  CString(x1);
      CString str_2 =  CString(x2);

And this should sort out the issue you are facing.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mr_stevieAuthor Commented:
Works like a charm!
Thanks mate!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.