RS>> You have to open the file before you can write to it.
TM> No. The ofstream constructor does that.
RS> Oh, really? I don't doubt it can be done, but is that the
RS> default or does that have to be implemented by you?
DM> Default.
JB> One little point however, opening a file stream like
JB> this writes to a file in textmode by default. One has
JB> to set ios::binary to write to a binary file. Or has
JB> this changed since my ancient TC++ 3.0 for Dos? ;-))
AFAIK, that's still the case. Not a major deal on unix systems, but seeing
as most of us here are on Intel, ... good thing to point out, Jan. Some
implementations use ios::binary, others use ios::bin. Unfortunately, I don't
know which one made it into the standard...
RS>> TM> ofstream("file1.fil") << name;
This would be:
ofstream("file1.fil", ios::out | ios::binary) << name;
Or, more likely in binary mode,
ofstream("file1.fil", ios::out | ios::binary).write(name, NAME_LEN);
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|