#include <sstream>
#include <iomanip>
std::stringstream strstream1,strstream2,strstream3,strstream4,strstream5;
strstream1 << std::setw(5) << std::setfill('0') << 5;//"00005"
strstream2 << std::hex << 16;//"10",std::dec or std::otc
int value;
strstream2 >> std::hex >> value;//value = 16
strstream3 << "0xFF";
strstream3 >> std::hex >> value;//value =255;没有std::hex value = 0
strstream4 << std::fixed << std::setprecision(3) << 33.1415;//"33.142"
strstream5 << std::showpoint << 3.;//"3.0000"
//stringstream可用于算数类型和字符串之间转换,同时c++11也新增函数用于转换
std::string str = std::to_string(41);
int v1 = std::atoi("10");
long v2 = std::atol("10");
unsigned long v3 = std::atoul("10");
long long v4 = std::atoll("10");
unsigned long long v5 = stoull("10");
folat v6 = stof("0.12");
double v7 = stod("0.12");
long double v8 = stold("0.3333");