Skip to content

Latest commit

 

History

History
70 lines (39 loc) · 2.54 KB

CppSaveContainer.md

File metadata and controls

70 lines (39 loc) · 2.54 KB

 

 

 

 

 

 

SaveContainer is a container and file I/O code snippet to save a container to file, one element per line.

 

 

 

 

 

SaveContainer using the G++ (version 4.4.1) compiler

 


//From http://www.richelbilderbeek.nl/CppSaveContainer.htm template <class Container> void SaveContainer(const Container& c, const std::string& filename) {   std::ofstream f(filename.c_str());   std::copy(c.begin(),c.end(),std::ostream_iterator<typename Container::value_type>(f,"\n")); }

 

 

 

 

 

 


//From http://www.richelbilderbeek.nl/CppSaveContainer.htm template <class Container> void SaveContainer(const Container& c, const std::string& filename) {   std::ofstream f(filename.c_str());   std::copy(c.begin(),c.end(),std::ostream_iterator<Container::value_type>(f,"\n")); }