I hope that the title was good enough to help explain what is needed. After solving this much of my project should be done.
When I did this
char e[1000] = "HELLO";
CString msg;
msg.Format(_T("%s"), e);
MessageBox(msg);
the messagebox just show me random words like "㹙癞鞮㹙癞鞮" instead of the "HELLO" i wanted. How do I solve this problem??
Helps would be appreciated. Thank You
First of all, are you really using MessageBox API that way. Check the MSDN Documentation. Now to your question,
char e[1000] = "HELLO";
CString msg;
msg.Format(_T("%S"), e); // Mind the caps "S"
MessageBox( NULL, msg, _T("Hi"), NULL );
I think, you do not even need to Format
data here. You can use::
TCHAR e[1000] = _T("HELLO") ;
MessageBox( NULL, e, _T("Hi"), NULL ) ;
This way, if _UNICODE is defined
, both TCHAR and MessageBox
would get chosen as WCHAR and MessageBoxW
and if not defined
as char and MessageBoxA
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With