全文预览

cprimerplus第五版编程题解

上传者:塑料瓶子 |  格式:pdf  |  页数:94 |  大小:6719KB

文档介绍
mfin("strings.dat@iosbase::iniosbase::binary);\rif(!fin.is_open())\r(\rcerrP”Couldnotopenfileforinput.\n\rexit(EXITFAILURE);\r)\rGetStrs(fin,vistr);\rcout<<h\nHerearethestringsreadfromthefile:\nz;\rforeach(vistr.begin(),vistr.end(),ShowStr);\rreturn0;\r)\rvoidShowStr(conststd::string&s)\r(\rstd::coutPs<<std::endl;\r}\rvoidStore::operator()(conststd::string&s)\r(\rstd::size_tlen=s.size();\ros.write((char*)&len,sizeof(std::size_t));\ros.write(s.data(),len);\r}\rvoidGetStrs(std::istream&is,std::vector<std::string>&vs)\r(\rstd::stringtemp;\rsize_tlen;\rwhile(is.read((char*)&len,sizeof(size_t))&&len>0)\r(\rcharch;\rtemp=;EvaluationWarning:ThedocumentwascreatedwithSpire.PDFfor.NET.\rfor(intj=0;j<len;j++)\r(\rif(is.read(&ch,1))\r(\rtemp+=ch;\r)\relse\rbreak;\r)\rif(is)\rvs.pushback(temp);\r)\r)

收藏

分享

举报
下载此文档