c++ stringstream 实现字符串与int之间的转换
作者:互联网
#include <iostream> #include <sstream> using namespace std; int main() { //string转int string str="10"; int num; stringstream ss; ss<<str; ss>>num; cout<<num+1; ss.clear();//将读写状态重置 ss.str("");//将内容置空 //int转string int num2=100; string str2; ss<<num2; ss>>str2; str2[0]='d'; cout<<str2; }
标签:string,int,str2,c++,num,stringstream,include 来源: https://www.cnblogs.com/CloudComputing-binbin/p/14787153.html