Re: [Dev-C++] A bit stumped on binary files
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel K. O. <dan...@ya...> - 2004-05-22 21:23:34
|
Ewald Horn wrote: >I do open the file as binary, using an IO stream. That's not the problem. I >need to know how to convert an integer value into it's 4 byte equivalent. > > No conversion is needed. Actually, your problem is that you ARE converting it to a string. The << operator is overloaded to convert the integer in a string representation of the value. You should be using the .write() method of the stream. Check this: http://www.cplusplus.com/ref/iostream/ostream/write.html >For instance 39184 is $00009910 and I would like to write [00,00,99,10] as >hex values to my file. > > In that case you'll need the << operator with the "hex" manipulator. http://www.cplusplus.com/ref/iostream/ios_base/_dec_hex_oct.html Daniel K. O. |