在C语言中:

       C函数有sprintf函数, 比较方便, 但是需要知道所需要的内存空间是多少.

在C++的框架MFC中:

        在MFC中CString 有Format函数来格式化字符串. 很方便.

难过的是:

       std::string没有格式化输入输出的Format函数.


只能通过

std::strstream进行转换

#include <sstream>
std::stringstream ss;
ss << 1234<< "wishchin" << 5678;
std::string  str = ss.str();

多写个一行,也算比较简单的.

相关文章:

  • 2022-12-23
  • 2022-01-02
  • 2021-11-02
  • 2022-03-02
  • 2022-12-23
  • 2021-07-02
  • 2021-11-12
猜你喜欢
  • 2022-12-23
  • 2021-07-21
  • 2021-09-19
  • 2022-12-23
  • 2021-09-13
  • 2022-02-22
  • 2021-11-21
相关资源
相似解决方案