现在的位置: 首页 > 综合 > 正文

使用stringstream转换类型

2013年09月12日 ⁄ 综合 ⁄ 共 428字 ⁄ 字号 评论关闭

//-------------------------------------
//功能:C++ int 转 string (使用stringstream)
//环境:VS2005
//-------------------------------------

#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
stringstream strStream;
int a = 100;
float f = 23.5566;

strStream << a << "----"<< f ;
string s = strStream.str();
cout << s << endl;

system("pause");
return 0;
}

文章地址:http://pppboy.blog.163.com/blog/static/302037962010378296766/

抱歉!评论已关闭.