#include <fstream>
#include <iostream>
#include <string>usingnamespace std;
int main()
{
fstream file,file1;
long size,first,end;
file.open("C:\\Example.txt",ios::in|ios::binary);
file1.open("D:\\Example2.txt",ios::out|ios::binary);
first=file.tellg();file.seekg(0,ios::end); // seek back to the beginning of your file before
// trying to extract any characters.
end=file.tellg();size=end-first;char a[size]; // non-constant size expression, does that even compile?
string line;for(int i=0;i<size;i++)while (!file.eof())
{
file>>a[i];file1<<a[i];getline(file, line);file1 << line;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Looks a tad more readable dont you think..? The lines in bold are where you had errors, my additions are in italics, and everything unnecessary I've put a line through.