how to write () a constant?
Larry Reznick
reznick at ribs.UUCP
Wed Jan 10 03:28:46 AEST 1990
In article <21689 at mimsy.umd.edu> chris at 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 at sacto.West.Sun.COM
More information about the Comp.lang.c
mailing list