On Apr 19, 9:58 pm, Ron Natalie <r...@spamcop.netwrote:
red floyd wrote:
shuisheng wrote:
I have question on file stream. I'd like the operator << to read and
write a variable in binary mode? For example,
#include <iostream>
int main()
{
ofstream f("output.dat");
double d = 3.1415926;
f << d; // I want d is written in binary mode. But here it is
written formatedly.
return 1;
}
the "<<" operator is for formatted output. Look at
std::basic_ostream<>::write().
Yes, all binary "mode" does is supress the mapping of \n into the
implementation specific new line sequence.
You know better than that. Binary mode suppresses an
implementation defined mapping of the '\n' and EOF, both of
which can be represented in many different ways on different
systems.
Under Windows, in text mode, '\n' maps to the two character
sequened 0x0D,0x0A, and '\x1A' is recognized as an EOF. But
that's a particularity of Windows; other systems have different
rules.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34