Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ucdavis!csusac!mmsac!ribs!reznick From: reznick@ribs.UUCP (Larry Reznick) Newsgroups: comp.lang.c Subject: Re: how to write () a constant? Message-ID: <241@heel.ribs.UUCP> Date: 9 Jan 90 16:28:46 GMT References: <10883@attctc.Dallas.TX.US> <21689@mimsy.umd.edu> Distribution: na Organization: Alldata Corp., Sacramento; Lines: 22 In-reply-to: chris@mimsy.umd.edu's message of 8 Jan 90 07:36:16 GMT In article <21689@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: > > int val = 1234; > if (fwrite((void *)&val, sizeof(val), 1, stream)) != sizeof(val)) > ... handle error ... > The comparison is mistaken. The fread() and fwrite() functions return their 3rd parameters if there's no error. So, the fragment should be written as: if (fwrite((void *) &val, sizeof(val), 1, stream)) != 1) { ... handle error ... } ---- -- Lawrence S. Reznick, KB6NSI Systems Software Engineer Alldata Corporation Phone: (916) 684-5200 FAX: (916) 684-5225 9412 Big Horn Blvd, Suite 6 UUCP: {sun!sacto,csusac}!ribs!reznick Elk Grove, CA 95758 INTERNET: ribs!reznick@sacto.West.Sun.COM