home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!munnari.oz.au!metro!mama!greyham
- From: greyham@research.canon.oz.au (Graham Stoney)
- Subject: Re: const char *p == char const *p ?
- Message-ID: <Bxzonp.2oH@research.canon.oz.au>
- Sender: news@research.canon.oz.au
- Organization: Canon Information Systems Research Australia
- References: <1992Nov15.162912.17454@news.uiowa.edu> <1992Nov16.010820.26757@cs.tu-berlin.de> <3870@dozo.and.nl>
- Date: Fri, 20 Nov 1992 00:43:01 GMT
- Lines: 29
-
- jos@and.nl (Jos Horsmeier) writes:
- >In article <1992Nov16.010820.26757@cs.tu-berlin.de> jutta@opal.cs.tu-berlin.de (Jutta Degener) writes:
- >|bonak@herky.cs.uiowa.edu (Esmail Bonakdarian) writes:
- >|> Is "char const *p" equivalent to "const char *p"?
- >|
- >|Yes. They are both pointers to constant character; you may
- >|change the pointer, but not the character it points to.
- >|
- >|Some programmers prefer "char const *" to "const char *".
- >|They argue that C declarations are read "inside out":
- >|
- >| char const * p ;
- >| ^ p is a
- >| ^ pointer to
- >| ^^^^^ constant
- >| ^^^^ char
- >|
- >|But that's just a matter of style.
-
- >Sorry, you're making a mistake, `const char * p' is _not_ equivalent
- >to `char * const p'. The first declaration reads: `there is a character
- >constant, and p points to it', while the second one reads: `this is
- >a character pointer p and it is a constant.'
-
- While Jos it correct in what he says about `char * const p', Jutta is not
- making a mistake, since they're talking `const char * p'.
-
- regs,
- Graham
-