????7??????????
????sstream??????????????????????????IO????Щ?????????stringд?????????string??????????string?????IO???????
????7.1 ???istringstream
????????????????????д???????????????????????????е?????????????????istringstream????????
???????磬????????????ζ????????????????е??????????????????vector?С?
????string line??word;
????while (getline(cin?? line))
????{
????vector<string> wordList;
????istringstream lineText(line);
????while (lineText >> word)
????{
????wordList.push_back(word);
????}
????}
????7.2 ???ostringstream
???????????????????????????????????ostringstream?????????????????????????????itoa??ftoa????????????????????
????int num1 = 42;
????double pi = 3.1415926;
????string str = "some numbers";
????ostringstream formatted;
????formatted << str << pi << num1;
????cout << formatted.str() << endl;
????????str?????????stringstream?м??????в???????
????string s;
????stringstream strm(s);// ????s????????????????????explicit???
????strm.str(); // ????strm???????string??????????
????strm.str(s); // ??s??????strm?У?????void??
????8?????????????? 8.1 ?????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????endl??????????????
???????????????????????????????????????????????????????????λ?????????????????????????????/??????????????????????????????????????????????????????臨??????????????????
????8.2 ????????????
???????????boolalpha?????bool???????true????true??false????false??????????noboolalpha????????????????????
????// modify boolalpha flag
????#include <iostream>     // std::cout?? std::boolalpha?? std::noboolalpha
????int main () {
????bool b = true;
????std::cout << std::boolalpha << b << ' ';
????std::cout << std::noboolalpha << b << ' ';
????return 0;
????}
????8.3 ?????????????
????????????????????????????????????ò??????????????????????????????
????oct???????????
????hex??????????????
????dec????????????
??????????????showbase???????????????????8??????????0??????????????0x???????noshowbase???cout?????????????????????????????????????????16??????????д??0X FF???????ò????uppercase??nouppercase??????????????Сд????
????cout << uppercase << showbase << hex << 20 << 1024
????<< nouppercase << noshowbase << dec << endl;
????8.4 ????????????
????????????????precision????????setprecision??????????????precision??????????????????汾????int???????????????????????????????????????????汾????????????????????????setprecision?????????????????????????t????
??????scientific??????????????????fixed??????????????hexfloat???????????????????defaultfloat?????????????????
????????showpoint?????????????С????
????8.5 ???????
????setw??????????????????????С???
????left???????????????
????right?????????????????????????????
????internal???????????????λ???????????????????????????????????м???
????setfill????????????????????????????????????
????int i = -16;
????double d = 3.14159;
????cout << "i:" << setw(12) << i << ' '
????<< "d:" << setw(12) << d << ' ';
????cout << left
????<< "i:" << setw(12) << i << ' '
????<< "d:" << setw(12) << d << ' ';
????cout << right
????<< "i:" << setw(12) << i << ' '
????<< "d:" << setw(12) << d << ' ';
????cout << internal
????<< "i:" << setw(12) << i << ' '
????<< "d:" << setw(12) << d << ' ';
????cout << setfill('#')
????<< "i:" << setw(12) << i << ' '
????<< "d:" << setw(12) << d << ' '
????<< setfill(' ');