[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppCopyFile
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppCopyFile
(C++) How do I copy a file?
A handy File I/O function.void copyFile(const std::string& fileNameFrom, const std::string& fileNameTo) { assert(fileExists(fileNameFrom)); std::ifstream in (fileNameFrom.c_str()); std::ofstream out(fileNameTo.c_str()); out << in.rdbuf(); out.close(); in.close(); }
- include <fstream>
- include <cassert>
Other code snippets
Topic list
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
