home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!princeton!newross!dynastar!blume
- From: blume@dynastar.Princeton.EDU (Matthias Blume)
- Subject: Re: Novice Questions
- Message-ID: <1992Aug31.210244.21471@newross.Princeton.EDU>
- Sender: news@newross.Princeton.EDU (USENET News System)
- Reply-To: blume@dynastar.Princeton.EDU (Matthias Blume)
- Organization: Dept. of Computer Science, Princeton University
- References: <1992Aug30.004740.8973@eskimo.celestial.com> <1992Aug31.093741.132@physc1.byu.edu>
- Date: Mon, 31 Aug 1992 21:02:44 GMT
- Lines: 38
-
- In article <1992Aug31.093741.132@physc1.byu.edu>,
- robertson@physc1.byu.edu writes:
- |> In article <1992Aug31.070123.23997@klaava.Helsinki.FI>,
- wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
- |> > Arrays and pointers are nowhere near equivalent. Superficially they
- |> > might look so, but that is only because arrays usually automatically
- |> > become pointers in C (but sometimes don't). For more information,
- |> > please read the FAQ of this group, section 2 especially.
- |> >
- |> > Btw, the person who said that array names are constant pointers might
- |> > want to look at questions 2.6.
- |>
-
- Sorry for bothering you -- I was the person who said this.
- Of course, I knew about the differences. I merely tried to
- suggest a simple ``rule of thumb'', how C novices might remember
- the most appearent difference between pointers and arrays:
- An array is not a lvalue! But most of the time, expressions of
- type ``array of T'' are converted to type ``pointer to T'', so
- it appears as if array-names were pointers.
- Here is the appropriate quote from K&R2 (page 200,
- App. A, par. A7.1 "pointer generation"):
-
- "If the type of an expression is 'array of T,' for some
- type T, then the value of the expression is a pointer to
- the first object in the array, and the type of the
- expression is altered to 'pointer to T.' This conversion
- does not take place if the expression is the operand to
- the unary & operator, or of ++, --, sizeof, or as the
- left operand of an assignment operator or the . operator.
- Similarly, an expression of type 'function returning T,'
- except when used as the expression operand of the & operator,
- is converted to `pointer to function returning T.'"
-
-
- -Matthias
-
-
-