• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1297
  • Last Modified:

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!
0
mr_stevie
Asked:
mr_stevie
  • 2
  • 2
1 Solution
 
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
 
mr_stevieAuthor Commented:
Works like a charm!
Thanks mate!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now