【求助】请问怎样把int类型转换为string类型?

renchao 2005-11-11 12:53:26
请问怎样把int类型转换为string类型?

试过IntToStr(),但只能把int转换为AnsiString,但从AnsiString又无法转换为string,
导致我使用cout << ansi_str;报错,说无法从AnsiString转换为string,郁闷。

谢谢指教!
...全文
99 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
maxuming914a1 2005-11-11
  • 打赏
  • 举报
回复
ding
shadowstar 2005-11-11
  • 打赏
  • 举报
回复
直接输出int不行吗?

std::cout << int_value;


按楼主的要求也可以:

int int_value;
std::string std_str;

std_str = IntToStr(int_value).c_str;

std::cout << std_str;
Maconel 2005-11-11
  • 打赏
  • 举报
回复
cout << ansi_str.c_str();

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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