Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ io fstream

Started by meisawesome Oct 20, 2006 at 7:52 AM 1 replies 1k views
Original Post
meisawesome
meisawesome
Hello I am writing a function to save a bitmap, and i am having a problem with file io I have simple code: std::ofstream OutBin("test.bin", std::ios_base::binary | std::ios_base::out); OutBin << 0xDEADBEEF; But right now that writes a 10 byte long file with contents "3735928559". I would like to know how I can get it to write a 4 byte long file with hex DEADBEEF.
Paulius Maruska
Paulius Maruska
operator << and operator >> (for istream) works with text output/input. That is, your data will be converted to/from text.
If you want to write/read bytes to/from stream (note - any stream, not only file stream), then you must use the stream methods write/read.
Just look up for those methods in your compilers help files.
meisawesome
meisawesome
:( That is what I thought.

Thanks for your help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.