void copy(const char *src, const char *dst) { std::cout << "copying " << src << " to " << dst << std::endl; Mmap<char> mmap; CHECK_DIE(mmap.open(src)) << mmap.what(); std::ofstream ofs(dst, std::ios::binary|std::ios::out); CHECK_DIE(ofs) << "permission denied: " << dst; ofs.write(reinterpret_cast<char*>(mmap.begin()), mmap.size()); ofs.close(); }
//--------------------------------- int main(){ ifstream in("abc.txt"); vector<string> abc; // abc.reserve(1100); Mmap nums; int n=0; for(string s; getline(in,s); ){ istringstream sin(s); int num=0; for(string t; sin>>t; num++); if(num){ nums.insert(Mmap::value_type(num, n++)); abc.push_back(s); } } for(Mmap::iterator it=nums.begin(); it!=nums.end(); ++it) cout<<abc[it->second]<<endl; getchar(); }//=================================