public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* ios::binary
@ 1998-11-03  9:52 Thomas Matelich
  1998-11-06  8:00 ` ios::binary rich_paul
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Matelich @ 1998-11-03  9:52 UTC (permalink / raw)
  To: egcs mailing list

So, binary file IO is unsupported?  Or am I mistaken?

--
Thomas O Matelich
Senior Programmer
Zetec, Inc.
tmatelich@zetec.com
tomsara@slip-stream.net




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ios::binary
  1998-11-03  9:52 ios::binary Thomas Matelich
@ 1998-11-06  8:00 ` rich_paul
  1998-11-07 18:30   ` ios::binary Tom and Sara and Emma
  0 siblings, 1 reply; 4+ messages in thread
From: rich_paul @ 1998-11-06  8:00 UTC (permalink / raw)
  To: Thomas Matelich; +Cc: egcs mailing list

Under unix, binary file IO is always the case.  Note that in the iostreams
library, binary means the same thing it means in ftp ... do not convert
line ends.  therefore:

{
  int i = 32;
  ofstream str("tempfile");
  str << i << endl;
}
{
  char ch;
  ifstream str("tempfile");
  str >> ch;
  cout << ch << endl;
}

will output the number 3, not a space, regardless of the binary flag.

--------
Where do you want to crash, toady?
On Tue, 3 Nov 1998, Thomas Matelich wrote:

> So, binary file IO is unsupported?  Or am I mistaken?
> 
> --
> Thomas O Matelich
> Senior Programmer
> Zetec, Inc.
> tmatelich@zetec.com
> tomsara@slip-stream.net
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ios::binary
  1998-11-06  8:00 ` ios::binary rich_paul
@ 1998-11-07 18:30   ` Tom and Sara and Emma
  1998-11-07 22:49     ` ios::binary Joe Buck
  0 siblings, 1 reply; 4+ messages in thread
From: Tom and Sara and Emma @ 1998-11-07 18:30 UTC (permalink / raw)
  To: rich_paul, egcs

I want to be able to write out binary data not character, like fwrite does, or
is that not the purpose of ios::binary?  ie, 4 bytes for a int, etc.

rich_paul@bigfoot.com wrote:

> Under unix, binary file IO is always the case.  Note that in the iostreams
> library, binary means the same thing it means in ftp ... do not convert
> line ends.  therefore:
>
> {
>   int i = 32;
>   ofstream str("tempfile");
>   str << i << endl;
> }
> {
>   char ch;
>   ifstream str("tempfile");
>   str >> ch;
>   cout << ch << endl;
> }
>
> will output the number 3, not a space, regardless of the binary flag.
>
> --------
> Where do you want to crash, toady?
> On Tue, 3 Nov 1998, Thomas Matelich wrote:
>
> > So, binary file IO is unsupported?  Or am I mistaken?
> >
> > --
> > Thomas O Matelich
> > Senior Programmer
> > Zetec, Inc.
> > tmatelich@zetec.com
> > tomsara@slip-stream.net
> >
> >
> >
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ios::binary
  1998-11-07 18:30   ` ios::binary Tom and Sara and Emma
@ 1998-11-07 22:49     ` Joe Buck
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Buck @ 1998-11-07 22:49 UTC (permalink / raw)
  To: Tom and Sara and Emma; +Cc: rich_paul, egcs

> I want to be able to write out binary data not character, like fwrite does, or
> is that not the purpose of ios::binary?  ie, 4 bytes for a int, etc.

No.  ios::binary puts the stream in binary mode on Windows or the Mac,
but even on those systems, with streams set to ios::binary, the
statements

	double v = 2.25;
	cout << v;

will still print characters.  (Things like end-of-line will change
behavior though).

The write method will write raw binary data to the stream, and is
analogous to fwrite.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-11-07 22:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-03  9:52 ios::binary Thomas Matelich
1998-11-06  8:00 ` ios::binary rich_paul
1998-11-07 18:30   ` ios::binary Tom and Sara and Emma
1998-11-07 22:49     ` ios::binary Joe Buck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).