Marc said:
What is the common way to do unformatted io
in c++?
read and write methods of the streams,
or fread and fwrite. Make sure that the stream or
FILE is opened in binary mode so that no bytes
are translated.
That means putting out everything just a a sequence of bytes.
And what is the most efficient way changing the endian while doing
io?
The most efficient method of changing endianness is to do this
all at once before the I/O is started. For example, to output
ten multi-byte integers:
1. Create a buffer / array to hold the integers.
2. Load the buffer with the data.
3. Change endianess of the data.
4. Write entire buffer with a single call to write() method.
The I/O is most efficient with fewer calls to large chunks of
data than many calls to small sized data. (Although to be
fair, you should make the measurements yourself on your
platform).
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library