C++????Щ??:????IO??
?????RonnyYoung ???????[ 2016/10/28 10:25:46 ] ????????C++ IO ??
????9?????????????
???????????????????????????????????????????????????λ????????????????????????У????????У??????????????????????????λ??seek??????λ?ò??????tell????????е???λ?á?
????9.1 seek??tell????
????seekg???????λ???????е???
????tellg?????????????б?????λ??
????seekp???????λ??????е???
????tellp????????????б?????λ??
???????????????istream????ifstream????istringstream?????g?汾???????????ostream???????????????ofstream????ostringstream??????p?汾??iostream????fstream????stringstream?????????????????????д??????????????汾??????汾??9.
????9.2 ?????????
?????????????????????????????????汾???????????????????????——??п???????????д????
????????????ifstream?????????tellp???????????????????????????????????
??????ü?????????д??fstream???????stringstream???????????????????????????????????????????е??λ???????????g?汾??p?汾????????????
????9.3 ???iostream??????????????????? 9.4 ?????λ???
????seekg??new_position??;
????seekp (new_position);
????seekg( offset?? dir);
????seekp( offset?? dir);
??????????汾?????λ???л????????????????汾?????????????????δ???????????????
????9.5 ??????
????tell????????????????????????pos_type????????檔
????10????????
????????????????????????????????????βд??????У????а????????п???????λ?????????д????е?????????????????0?????????????????????
????abcd
????efg
????hi
????j
??????γ????????????????????£?
????abcd
????efg
????hi
????j
????5 9 12 14
????#include <iostream>
????#include <fstream>
????#include <string>
????using std::fstream;
????using std::cerr;
????using std::endl;
????using std::ifstream;
????using std::ofstream;
????using std::string;
????using std::getline;
????using std::cout;
????//using namespace std;
????int main()
????{
????fstream inOut("copyOut.txt"??
????fstream::ate | fstream::in | fstream::out); //??ate??????????????λ???λ??????β??
????if( !inOut ) {
????cerr << "unable to open file" <<endl;
????return EXIT_FAILURE;
????}
????inOut.seekg(-1??fstream::end); //go to the last char
????if( inOut.peek() != 10) //if the last char of the file is not a newline??add it.
????{
????inOut.seekg(0??fstream::end);
????inOut.put(' ');
????}
????inOut.seekg(0??fstream::end);
????ifstream::pos_type endMark = inOut.tellg(); //record the last position .
????inOut.seekg(0??fstream::beg);
????int cnt = 0; //accumulator for byte count
????string line; //hold each line of input
????while( inOut && inOut.tellg() != endMark
????&& getline(inOut ?? line)
????)
????{
????cnt += line.size() + 1; // add 1 to acount for the newline
????ifstream::pos_type mark = inOut.tellg();
????inOut.seekp( 0?? fstream::end); //set write marker to end
????inOut << cnt;
????if( mark != endMark) inOut << " ";
????inOut.seekg(mark); //restore read position
????}
????inOut.clear(); //clear flags in case we hit an error
????inOut.seekp(0 ?? fstream::end); //seek to end
????inOut << endl; //write a newline at end of file
????return 0;
????}
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????