#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; }