Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!mordor!styx!lll-lcc!ames!ucbcad!ucbvax!decvax!mcnc!rti-sel!dg_rtp!meissner From: meissner@dg_rtp.UUCP Newsgroups: comp.lang.c Subject: Re: C questions Message-ID: <954@dg_rtp.UUCP> Date: Tue, 3-Feb-87 09:54:56 EST Article-I.D.: dg_rtp.954 Posted: Tue Feb 3 09:54:56 1987 Date-Received: Thu, 5-Feb-87 04:54:33 EST References: <2335@brl-adm.ARPA> <194@olamb.UUCP> Reply-To: meissner@dg_rtp.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 28 In article <194@olamb.UUCP> kimcm@olamb.UUCP (Kim Chr. Madsen) writes: > > ... Just consider the example: > > struct p { > int p_num; > char name[20]; > char phone[12]; > } person; > > while (read(fd,&person,sizeof(person)) == sizeof(person)) { > ...do something to person structure... > } 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... */ } -- Michael Meissner, Data General ...mcnc!rti-sel!dg_rtp!meissner