From: "Tim 'Zastai' Van Holder" Newsgroups: comp.os.msdos.djgpp References: <8o1930$36j$1 AT info DOT cyf-kr DOT edu DOT pl> Subject: Re: binary I/O bug ? Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <35ep5.27500$Ee.200783@afrodite.telenet-ops.be> Date: Thu, 24 Aug 2000 18:47:27 GMT NNTP-Posting-Host: 213.224.92.242 X-Trace: afrodite.telenet-ops.be 967142847 213.224.92.242 (Thu, 24 Aug 2000 20:47:27 MET DST) NNTP-Posting-Date: Thu, 24 Aug 2000 20:47:27 MET DST Organization: Pandora - Met vlotte tred op Internet To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Rafał Maj" wrote in message news:8o1930$36j$1 AT info DOT cyf-kr DOT edu DOT pl... > I think ther is bug in I/O binary mode : > > 1) > I can't open ofstream / ifstream in ios::binary mode. > When I use : > ifstream plik; plik.open("test.txt",ios::binary); plik<<"OK ;)"; > plik.close(); > then test.txt is empty. When I don't use ios::binary, then everything is OK. No, that means there's a bug in non-binary mode: You're using an input stream for output. Try using 'ofstream plik;' instead. You may also want to explicitly mention that you're doing output (ie use 'ios::binary | ios::out' as arg to open()). > 2) Functions write / read from class ifstream/ofstream, with should be > always binary, are working like in text mode (changing some chars, I think > it was #13 -> #10 #13 or somethink like this) Wrong. read and write are supposed to behave according to the flags passed on open; so they should only do binary I/O if you passed ios::binary. -- excerpt from the ANSI standard -- basic_ostream& write(const char_type* s, streamsize n); * Effects: Obtains characters to insert from successive locations of an array whose first element is designated by s. * Characters are inserted until either of the following occurs: - n characters are inserted; - inserting in the output sequence fails (in which case the function calls setstate(badbit), which may throw ios_base::failure (27.4.4.3)). -- end excerpt -- So it simply inserts chars into the underlying streambuf; UNFORMATTED, yes, but not without binary/text handling. > QUESTION : > Where I can download new version of DJGPP that don't have this bug, > or how can I do workaround of this bug ? Workaround: Learn the language properly before complaining about the compiler. Please direct further such questions to comp.lang.c++. -- Hi, I'm a signature virus. plz set me as your signature and help me spread :)