Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 (MU) 9/23/84; site munnari.OZ Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!dcdwest!ittvax!decvax!mulga!munnari!taso From: taso@munnari.OZ (Taso Hatzi) Newsgroups: net.lang.c Subject: Re: sizeof and array parameters Message-ID: <618@munnari.OZ> Date: Fri, 28-Dec-84 08:33:57 EST Article-I.D.: munnari.618 Posted: Fri Dec 28 08:33:57 1984 Date-Received: Sun, 30-Dec-84 01:46:46 EST References: <6794@brl-tgr.ARPA> Reply-To: taso@munnari.OZ (Taso Hatzi) Organization: Comp Sci, Melbourne Uni, Australia Lines: 39 In article <6794@brl-tgr.ARPA> Craig Partridgewrites: > >#define ARRAYSIZE 4 > >readarray(fd,a) >int fd; >int a[ARRAYSIZE]; >{ > read(fd,a,sizeof(a)); >} > Might I suggest that what you really meant was: #define ARRAYSIZE 4 readarray(fd, a) int fd; int (*a)[ARRAYSIZE]; { read(fd, a, sizeof(*a)); } You should find the last two paragraphs of K & R p94 informative. I think it's unfortunate that f(x) int x[N]; { } is a legitimate way of declaring an array argument. It has made it practically impossible to allow for arrays to be passed by value. On the other hand, given that arrays will never be passed by value, it does make array references from inside the function look tidier.