C++整数转string


#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();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM