03-25-2015 08:25 AM
hello people,
I try to cast a CString in char* but it only take the first character
CString sox =(CString)"A060," ;
char* pChar = (char*)(LPCTSTR)(CString)sox ;
after i built it, there is only the character "A" in pChar and not "A060,"
HELP !!!!
04-13-2015 09:08 AM
Hi,
What do you use to display pChar?
As pChar is pointing a Cstring, you have to display it as a CString.
If you use a printf it will display A, you have to use _tprintf.
source: https://msdn.microsoft.com/en-us/library/ms174288.aspx
Example:
int main()
{
CString sox =(CString)"A060," ;
char* pChar = (char*)(LPCTSTR)(CString)sox ;
_tprintf(_T("char=%s\n"), pChar);
}
Result:
char= A060.
Best regards,