fstream file;
file.open("infile.txt",ios::ate); //opens a file, infile.txt and sets the "cursor" to the end
char* data=newchar[1024];
int size=file.tellg(); //get the size of the file(no of bytes to copy)
file.seekg(0); //set the get pointer to the beginning
file.read(data,size);//copy size(all) data into the buffer called data
file.close();
file.open("outfile.txt",ios::beg);//open outfile.txt to copy data to
file.write(data,size);//also writes all charactes in data to the outfile.txt
file.close();