Message-ID: <3633DDE8.9016BCDE@montana.com> Date: Sun, 25 Oct 1998 19:26:48 -0700 From: bowman X-Mailer: Mozilla 4.5b2 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: fstream ios::binary problem References: <36339807 DOT 18DBCCF6 AT arctic DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com "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.