Ash*_*ton 5 c++ mfc char cstring
我希望标题足以帮助解释需要什么。解决了这个问题后,我的大部分项目应该完成了。
当我这样做时
char e[1000] = "HELLO";
CString msg;
msg.Format(_T("%s"), e);
MessageBox(msg);
Run Code Online (Sandbox Code Playgroud)
消息框只是向我显示诸如“??????”之类的随机词 而不是我想要的“你好”。我该如何解决这个问题??
帮助将不胜感激。谢谢你
首先,你真的是这样使用 MessageBox API 的吗?检查MSDN 文档。现在回答你的问题,
char e[1000] = "HELLO";
CString msg;
msg.Format(_T("%S"), e); // Mind the caps "S"
MessageBox( NULL, msg, _T("Hi"), NULL );
Run Code Online (Sandbox Code Playgroud)
我想,你甚至不需要Format这里的数据。您可以使用::
TCHAR e[1000] = _T("HELLO") ;
MessageBox( NULL, e, _T("Hi"), NULL ) ;
Run Code Online (Sandbox Code Playgroud)
这样,如果_UNICODE is defined,两者TCHAR and MessageBox都会被选择为WCHAR and MessageBoxW和 if not definedas char and MessageBoxA。
| 归档时间: |
|
| 查看次数: |
10846 次 |
| 最近记录: |