I am trying to copy an exe file byte by byte. I compared the hex files of the 2 and they are quite different. It seems like some values are not getting loaded in..
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main(){
ifstream fin("file.exe", ifstream::binary);
vector<char> buffer(1, 0);
ofstream newfile;
newfile.open("newfile.exe", ios::binary);
while (fin.read(buffer.data(), buffer.size())){
streamsize s = fin.gcount();
for (int i = 0; i < buffer.size(); i++){
if (buffer[i] != EOF){
newfile << buffer[i];
cout << buffer[i] << endl;
} else {
break;
}
}
}
}