Why doesn't this program make a carbon copy? The output file is smaller than its counterpart and does not function.
Code:#include <cstdlib> #include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]) { unsigned long int x = 0; unsigned char buffer; ifstream reader("C:\\windows\\desktop\\1.jpg", ios::in | ios::binary); ofstream writer("C:\\windows\\desktop\\1_out.jpg", ios::out | ios::binary); if(reader.fail()) {cout << "Failed to open file" << endl; return 1;} if(writer.fail()) {cout << "Failed to open write stream" << endl; return 1;} while(!reader.eof()) { reader >> buffer; if(x < 100) cout << buffer; writer << buffer; x++; } cout << x << endl; reader.close(); writer.close(); system("PAUSE"); return EXIT_SUCCESS; }