Click here to Skip to main content
11,705,610 members (46,051 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC
Hey guys,

I really don't know anymore how to converte char to CString in MFC.
Can somebody help me please?


Greetings
Epanjohura
Posted 28-Sep-12 2:10am
Edited 28-Sep-12 2:24am
CPallini353.8K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can just use the overloaded assignment operator/constructor/copy constructor of CString.

CString strVarible;
strVarible = CString('a');

For more details :
See this[^]

[Edit :- Removed the wrong code I pasted mistakenly.]
  Permalink  
v4
Comments
epanjohura at 28-Sep-12 8:43am
   
thanks a lot =)
Malli_S at 17-Feb-14 2:22am
   
Welcome.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You may use the CString constructor for such a task. e.g.
CString s1(_T('a')); // from single character
CString s2(_T("foo")); // from string literal
  Permalink  
v2
Comments
CPallini at 28-Sep-12 8:29am
   
Thank you for the fix.
epanjohura at 28-Sep-12 8:44am
   
thanks a lot =)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 160
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100