首页 服务器 编程 必备知识 搜索引擎 圩日手册
站内搜索
最近浏览
推荐文章
热文排行

C++ 中int 和string 的类型转换


//int to string add string to int

#include<iostream>
#include<conio.h>//getch()
#include<string>
#include<sstream>
using namespace std;

void main()
{
 int b=121234,a;
 string str,st="7894456";
 stringstream istr,stri;
 
//int to string
 istr<<b;
 istr>>str;
//string to int
 stri<<st;
 stri>>a;


 cout<<a<<endl;
 cout<<str<<endl;
 
// int i=str.length();
// cout<<i<<endl;

 cout<<sizeof(a)<<endl;
 cout<<sizeof(str)<<endl; //check the type

 getch();
// system("pause");

[wangjy17908]
添加时间:2008-03-04
版权所有(C)2005-2015