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")); }
SaveContainer using the C++ Builder 6.0 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<Container::value_type>(f,"\n")); }