#include <fstream>
#include <iostream>
using namespace std;
int main()
{
const int LEN = 4096;
char buf[LEN];
ifstream fin("demo1.pdf", ifstream::in | ifstream::binary);
ofstream fout("demo2.pdf", ofstream::out | ofstream::binary);
if(!fin || !fout)
{
cerr << "File Error" << endl;
return EXIT_FAILURE;
}
while(!fin.eof())
{
fin.read(buf, LEN);
fout.write(buf, fin.gcount());
}
return EXIT_SUCCESS;
}