I'm trying to write simple c++ code to read and write a file. The problem is my output file is smaller than the original file, and I'm stuck finding the cause. I have a image with 6.6 kb and my output image is about 6.4 kb
#include <iostream> #include <fstream> using namespace std; ofstream myOutpue; ifstream mySource; int main() { mySource.open("im1.jpg", ios_base::binary); myOutpue.open("im2.jpg", ios_base::out); char buffer; if (mySource.is_open()) { while (!mySource.eof()) { mySource >> buffer; myOutpue << buffer; } } mySource.close(); myOutpue.close(); return 1; }