home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!and!jos
- From: jos@and.nl (Jos Horsmeier)
- Newsgroups: comp.lang.c
- Subject: Re: const char *p == char const *p ?
- Message-ID: <3870@dozo.and.nl>
- Date: 16 Nov 92 10:32:00 GMT
- References: <1992Nov15.162912.17454@news.uiowa.edu> <1992Nov16.010820.26757@cs.tu-berlin.de>
- Organization: AND Software BV Rotterdam
- Lines: 30
-
- 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.'
-
- Using `char * const p' without an explicit initialization is quite
- silly, because assigning a value to p later on in the code, is
- not allowed. I do agree that the syntax is a bit confusing ...
-
- kind regards,
-
- Jos aka jos@and.nl
-