Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!prls!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c,net.micro.pc,net.unix Subject: Re: C'mon, guys! Message-ID: <3904@sun.uucp> Date: Wed, 4-Jun-86 00:08:03 EDT Article-I.D.: sun.3904 Posted: Wed Jun 4 00:08:03 1986 Date-Received: Thu, 5-Jun-86 08:08:55 EDT References: <200@pyuxv.UUCP> <1181@ncoast.UUCP> <350@dg_rtp.UUCP> Followup-To: net.lang.c Organization: Sun Microsystems, Inc. Lines: 30 Xref: linus net.lang.c:8512 net.micro.pc:8128 net.unix:7346 > Or do we have confusion between name and object? > ... > So an array is not a pointer but a reference to an array > in an expression is a pointer. That's part of it, but I strongly suspect that people have been confused by the fact that when you use an array name in an expression it really means a pointer to the first member of the array; they interpret this limited interchangability as meaning pointers and arrays are equivalent. There's been a discussion in net.lang.c of features to be added to C; sometimes I think pointers should be *subtracted* from C, since people seem to get very confused about them. There's plenty of code out there which indicates that the author thinks that, because the second argument to "stat" is a "struct stat *", that you *have* to pass it a variable of type "struct stat *" as its second argument; they declare such a variable, set it to point to a declared "struct stat", and pass the variable to "stat" instead of just "&". Of course, there's always the code which doesn't declare the "struct stat", and doesn't initialize the pointer, but just passes a pointer which points nowhere to "stat"; this pops up every so often on net.lang.c with the question "Why doesn't this work?" attached. OK, maybe they're useful, and shouldn't be removed. C classes should spend *lots* more time on them than they are doing, though, given these problems; better that people learn in class before they start writing code, than be forced to ask several thousand people on USENET why their code doesn't work. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)