MFC: String* to const char* or String* to char Conversion

How can I convert a String* in MFC to const char* mychar or char mychar[MAX_PATH] ?

[90 byte] By [BigguyGraves] at [2008-1-12]
# 1
I'd assume you mean a CString* rather then a String*. If you really do mean String, can you reference the header file it is declared in?

In MFC 8.0 CString is a typedef for CStringT, which inherits from CSimpleStringT.

The following are references for the methods and operator allowing direct access to the string contained in the CSimpleStringT, and thus the CString:

http://msdn2.microsoft.com/library/ysk0ddz5.aspx
http://msdn2.microsoft.com/library/tk1z2hd9.aspx
http://msdn2.microsoft.com/library/k59cayc6.aspx

The list of methods for CSimpleStringT can be found at:
http://msdn2.microsoft.com/library/8fx6d2h7.aspx

The list of methods for CStringT can be found at:
http://msdn2.microsoft.com/library/abzc9989.aspx

JoshHeitzman-MSFT at 2007-8-21 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 2
1.
CString *pStr; // string must be initialized!
const char *mychar = (const char*)LPCTSTR(*pStr);

2.
CString *pStr; // string must be initialized!
char *mychar = new char[(MAX_PATH + 1) * sizeof(TCHAR)];
memset(mychar, 0, (MAX_PATH + 1) * sizeof(TCHAR));
memcpy(mychar, (const char*)LPCTSTR(*pStr), pStr->getLength() * sizeof(TCHAR));
om-by at 2008-1-28 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...