Problem: How to convert CString into const char * in C++ MFC
c++, mfc, visual-c++
Solution
CString casts to const char * directly
CString temp;
temp = "Wow";
const char * foo = (LPCSTR) temp;
printf("%s", foo);
will print 'foo'
Newer version of MFC also support the GetString() method:
CString temp;
temp = "Wow";
const char * foo = temp.GetString();
printf("%s", foo);
Problem
How do I convert CString into const char *? I have tried everything found on the internet but I still cant convert them. Please help. Thank you.