🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2103

Re: fwrite+fread of pointer

#2103
From: Steve Clamage
Date: Fri, 13 Nov 1992 18:44
21 lines
1049 bytes
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:

>I would like to know what the standard says about the following program:

[ writes the contents of a pointer with fwrite, reads it back with fread ]

>What I want to know is whether, assuming nothing else goes wrong, the
>program _must_ print 1 or whether it may print 0.

[ that is, whether the value read == the value written ]

ANSI C Standard 4.9.2:

"Data read in from a binary stream shall compare equal to the data that
were earlier written out to the stream, under the same implementation."

In the example, the file was opened in binary mode, so this applies.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Technical Details
Message-ID: <1992Nov13.184421.11065@taumet.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
References: <15935@goanna.cs.rmit.oz.au>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
From: steve@taumet.com (Steve Clamage)
Subject: Re: fwrite+fread of pointer
Message-ID: <1992Nov13.184421.11065@taumet.com>
Organization: TauMetric Corporation
References: <15935@goanna.cs.rmit.oz.au>
Date: Fri, 13 Nov 1992 18:44:21 GMT
Lines: 21