#include "stdafx.h" #include "string" #include "iostream" #include "vector" #include "sstream" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { //string 转 int stringstream ss; string str; int i; ss<<"100"; ss>>i; i=i+100; cout<<i<<endl;//输出结果200 //int 转 string stringstream ssm; ssm<<5; str=ssm.str(); str=str+"8"; cout<<str;//输出结果58 getchar(); return 0; }
#include "stdafx.h" #include "string" #include "iostream" #include "vector" #include "sstream" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { //string 转 int stringstream ss; string str; int i; ss<<"100"; ss>>i; i=i+100; cout<<i<<endl;//输出结果200 //int 转 string stringstream ssm; ssm<<5; str=ssm.str(); str=str+"8"; cout<<str;//输出结果58 getchar(); return 0; }
时间: 2024-11-05 23:45:20