This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 10th, 2012  |  syntax: C++  |  size: 0.36 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <fstream>
  2. #include <vector>
  3. #include <iterator>
  4.  
  5. int main()
  6. {
  7.     std::ifstream ifs("test.txt");
  8.     ifs.unsetf(std::ios::skipws);
  9.     std::vector<char> buf(
  10.         (std::istream_iterator<char>(ifs)),
  11.          std::istream_iterator<char>());
  12.     std::ofstream ofs("testcopy.txt", std::ios::binary);
  13.     ofs.write(buf.data(), buf.size());
  14. }
clone this paste RAW Paste Data