Click here to Skip to main content
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 3:10am
Edited 28-Sep-12 3:24am
CPallini333.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 Dnyaneshwar@Pune 719
1 CPallini 245
2 TheRealSteveJudge 240
3 CHill60 235
4 Umer Akram 190
0 Sergey Alexandrovich Kryukov 9,078
1 OriginalGriff 6,771
2 Peter Leow 4,282
3 Zoltán Zörgő 3,809
4 Richard MacCutchan 2,661


Advertise | Privacy | Mobile
Web04 | 2.8.150128.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