#include <iostream>
#include <sstream>

using namespace std;


int main(void)
{
    stringstream ss;
    int i=0;
    for(i=0;i<=100;i++)
    {
        ss<<i;
    }
    string s=ss.str();

    cout<<s<<endl;

    system("pause");
}

首先包含头文件

#include <sstream>

定义字符流变量

stringstream ss;

将ss转化成字符串

string s=ss.str();

 

相关文章:

  • 2021-07-14
  • 2021-07-02
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2022-02-18
  • 2021-12-27
  • 2022-01-20
  • 2021-10-24
  • 2021-10-04
相关资源
相似解决方案