【C++】:stringToInt intToString

#include <sstream>
#include <string>
using namespace std;

int main()
{
    // intToString
   stringstream ss;
   int num = 123456;
   ss << num;
   string s = ss.str();
   if (!ss.good())
   {
       //error
   }

   //StringToInt
   stringstream ss2;
   string arr = "1234567";
   ss2 << arr;
   int num2;
   ss2 >> num2;
   if (!ss.good())
   {
       //error
   }
    return 0;
}

你可能感兴趣的:(C++,IntToString,StringToInt)