Convert CString to character array?

yesraaj picture yesraaj · Apr 24, 2009 · Viewed 50.7k times · Source

How to convert CString in MFC to char[] (character array)

Answer

sharptooth picture sharptooth · Apr 24, 2009

You use CString::GetBuffer() to get the TCHAR[] - the pointer to the buffer. If you compiled without UNICODE defined that's enough - TCHAR is same as char, otherwise you'll have to allocate a separate buffer and use WideCharToMultiByte() for conversion.