[ create a new paste ] login | about

Link: http://codepad.org/g3p2wW9w    [ raw code | output | fork ]

C++, pasted on Sep 25:
#include <iostream>
#include <fstream>
#include <list>
#include <iterator>

int main(){
  std::ifstream data( "input.dat" );
  if ( !data ) {
    std::cerr << "input file open error";
    return 1;
  }
  data.unsetf(std::ios::skipws);
  std::list<char> chars;
  std::copy( std::istream_iterator<char>(data),
             std::istream_iterator<char>(),
             std::inserter( chars, chars.begin() ) );
  std::cout << "size:" << chars.size() << std::endl;
  std::ofstream out( "output.dat" );
  if ( !out ) {
    std::cerr << "output file open error";
    return 1;
  }
  std::copy( chars.begin(),
             chars.end(),
             std::ostream_iterator<char>( out ) );
}


Output:
1
input file open error


Create a new paste based on this one


Comments: