I am using visual studio 2010 MFC to build a C++ program. My program calls a DLL that is not apart of the project and it accepts a char*. I have a function that gets a string in
In MFC the easiest is to convert through CStringA (provided that resulting buffer will be a read-only argument):
LPCTSTR pszA = ...
CStringA sB(pszA);
const char* pszC = sB;
char* pszD = const_cast(pszC);
Other options are available and were discussed:
WideCharToMultiByte, T2A macros etc.