delorie.com/archives/browse.cgi | search |
Message-ID: | <36339807.18DBCCF6@arctic.net> |
From: | "Benjamin R. Saylor" <bsaylor AT arctic DOT net> |
X-Mailer: | Mozilla 4.05 [en] (Win95; I) |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | fstream ios::binary problem |
Lines: | 19 |
Date: | Sun, 25 Oct 1998 12:28:39 -0900 |
NNTP-Posting-Host: | 198.51.13.2 |
X-Complaints-To: | support AT newshosting DOT com |
X-Trace: | news.siscom.net 909351049 198.51.13.2 (Sun, 25 Oct 1998 16:30:49 EDT) |
NNTP-Posting-Date: | Sun, 25 Oct 1998 16:30:49 EDT |
Organization: | Newshosting |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
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? #include <fstream.h> #include <math.h> void main() { short wave[11025]; ofstream output("temp.raw", ios::binary); for (int sample = 0; sample < 11025; sample++) { wave[sample] = (short) (32767*sin(.01*sample)); output << wave[sample]; } }
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |