Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!seismo!mcvax!diku!olamb!kimcm From: kimcm@olamb.UUCP Newsgroups: comp.lang.c Subject: Re: C questions Message-ID: <197@olamb.UUCP> Date: Thu, 12-Feb-87 07:00:56 EST Article-I.D.: olamb.197 Posted: Thu Feb 12 07:00:56 1987 Date-Received: Thu, 19-Feb-87 06:27:13 EST References: <2335@brl-adm.ARPA> <194@olamb.UUCP> <954@dg_rtp.UUCP> Organization: AmbraSoft A/S (Denmark) Lines: 27 In article <954@dg_rtp.UUCP>, meissner@dg_rtp.UUCP (Michael Meissner) writes: ] In article <194@olamb.UUCP> kimcm@olamb.UUCP (Kim Chr. Madsen) writes: ] ] [Some code of mine...] ] ] Let's indead consider this example. This is wrong, wrong, wrong (even ] though it may happen to work on your system). The second argument to ] read is a char *, not a structure pointer. To pass lint (and to have ] it work on word-based machines), it should read: ] ] /* ... */ ] ] while (read(fd, (char *) &person,sizeof(person)) == sizeof(person)) { ] /* ...do something to person structure... */ ] } Well, I made a mistake, I wrote the code on the spot and forgot to cast the struct pointer to a char pointer. Yes I know they have different types, but that doesn't make the example (of proving sizeof as essential knowledge to a C programmer) invalid. Kindly Regards Kim Chr. Madsen