I am trying to copy some binary source file to a target file. This seems to be the most popular way to do it.
Here it is in a simple test application:
#include "stdafx.h"
#include <fstream>
int main(int argc, const char* argv[])
{
using namespace std;
string sourceFile(argv[1]);
string targetFile(argv[2]);
ifstream src(sourceFile);
ofstream dst(targetFile);
dst << src.rdbuf();
return 0;
}
If I build and run this example in Visual Studio 2010, only the first 522 bytes of the file are copied. Why is this so? And how can I extend this example to ensure all bytes are copied?