将整数型数添加到CListBox上

fanciszek 2008-05-14 06:25:31
CString str;
str.Format("%d",p);
m_datalist.AddString(str);
其中p为int型,m_datalist是添加在一个Listbox控件上的Control型CListBox数值,想把p添加在m_datalist中,运行时提示错误:
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>e:\laddy.cpp(121) : error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *'
请问怎么解决,急
...全文
50 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnzdgs 2008-05-14
  • 打赏
  • 举报
回复
你的项目是使用Unicode字符集的。

str.Format(_T("%d"),p);
或者
str.Format(L"%d",p);
devang 2008-05-14
  • 打赏
  • 举报
回复
str.Format(_T("%d"),p);

18,363

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧