Mail Archives: djgpp/1998/10/25/20:29:40
"Benjamin R. Saylor" wrote:
>
> I wrote this code to write a series of numbers (short wave[11025]) to a
> binary file. the program produces a 57k file (rather than 22k) and I
> looked at it in ms-dos editor to discover that the program output the
> numbers as text, like cout would. Why doesn't ios::binary work?
ios::binary isn't your problem, it is the 'put to' operator <<. Think of
it
as sort of a hardwired fprintf. the << for any built-in type has one
mission in
life: turning that data into a formatted textual representation. see
Stroustrup's 3rd,
21.2.2
try the 'write' ostream class member. don't
let the 'char' in the prototype throw you, you just need to pass
&someval and sizeof(someval) to write ints, doubles, structures, or
what have you.
- Raw text -