Click here to Skip to main content
12,505,902 members (47,948 online)
Rate this:
 
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
Updated 28-Sep-12 2:24am
CPallini389.6K
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 28-Sep-12 8:43am
   
thanks a lot =)
Malli_S 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 28-Sep-12 8:29am
   
Thank you for the fix.
epanjohura 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2016
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