Reputation: 4790
I'm trying to upload a photo to one of our server in C++, the following is an excerpt of my testing code
//in main
ifstream fin("cloud.jpg");
ofstream fout("cloudcpy.jpg");
string data;
while ( fin )
fin >> data;
fout << data;
fin.close();
fout.close();
return 0;
But the output file is not a copy, much more smaller than the original one. Anything wrong in my code?
Upvotes: 0
Views: 840
Reputation: 147
You may not use string as the data type. Since JPEG file is not a textfile. Please try to use primitive type such as unsigned char or unsigned int to do it.
Upvotes: 0