From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Writing a struct to disk Date: Mon, 25 Aug 1997 19:04:56 -0700 Organization: Alcyone Systems Lines: 47 Message-ID: <340239C8.55CEBE3B@alcyone.com> References: <1 DOT 5 DOT 4 DOT 32 DOT 19970825173441 DOT 006ab780 AT dce03 DOT ipt DOT br> <5tt2p5$o6s AT dfw-ixnews5 DOT ix DOT netcom DOT com> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk firewind wrote: > Unlike some fortunate people, I don't have a copy of the ANSI standard > handy, > but in K&R2, chapter 7, section 1, is is said: > > "A text stream consists of a sequence of lines; each line ends with a > newline > character. If the system doesn't operate that way, the library does > whatever > is necessary to make it appear as if it does. For instance, the > library might > convert carriage return and linefeed to newline on input and back > again on > output." > > Someone please correct me if this is not actually garunteed by the > ANSI > standard. This is true in ANSI as well: If you write out a file in text mode, it will be translated to the native end-of-line sequences. Similarly if you read in a text file with the native end-of-line sequences, it will be translated to newlines. However, you are _not_ guaranteed that a text file on one system will work as a text file on another system. As such, that hardly makes text mode "portable" (which was the original poster's claim). > The only functions is C that -rely- on a certain character set are the > ctype > macros. If you read a character into a variable and compare it with a > certain > character, the comparison will correctly work for all character sets. Yes, but the point is that you're not even guaranteed that the newline will be the same character on two systems. ANSI C even makes a distinction between the "source" and "execution" character sets (ANSI 5.2.1). -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm://37.20.07n/121.53.38w \ "War is like love; / it always finds a way." / Bertolt Brecht