Problems with converting files to binary c++ studio 2012 -
i'm writing simple programme transforms file original type binary form.
however, i'm having next problem. code compiles correctly when run it, console window opens , never closes until close myself. also, have noticed longer console window stays open, larger size of newly created binary file be. below code:
#include <fstream>//to open file using namespace std; int main(void){ ifstream in("in.jpg"); ofstream out("out.bin", ios::binary); double d; while(!in.eof()) { out.write((char*)&d, sizeof d); } out.close(); in.close(); homecoming 0; }
you never read in
, hence has no chance of ever hitting eof
.
also, using eof
in loop conditions lead wrong results, explained in next question: why iostream::eof within loop status considered wrong?
(generally, it's unclear you're trying do. .jpg
'binary' format, there no sensible notion of 'converting .jpg
file binary'.)
c++ binary jpeg
No comments:
Post a Comment