Re: off topic question
- From: Soeren Sandmann <sandmann daimi au dk>
- To: "Rich Gautier" <rgautier cox net>
- Cc: "Scott Barron" <sb125499 ohiou edu>, <gtk-app-devel-list gnome org>
- Subject: Re: off topic question
- Date: 27 Jul 2002 15:17:30 +0200
"Rich Gautier" <rgautier cox net> writes:
However, I have a follow-on question - isn't it the pointer itself that is
declared constant, not the character array that it points to?
No, C declarations should be read "inside out", so
const char *s;
should be read as "s is a pointer to (const char)", ie., s points to
characters you can't change.
The declaration
char *const s;
means "s is a constant pointer to characters", ie., you can't change
where s points, but you can change the characters it points to.
The program cdecl is helpful:
horse09:~% cdecl
Type `help' or `?' for help
cdecl>
cdecl> explain const char *s;
declare s as pointer to const char
cdecl>
cdecl> explain char *const s;
declare s as const pointer to char
cdecl>
cdecl> explain const char *const s;
declare s as const pointer to const char
cdecl>
cdecl> declare s as const pointer to char
char * const s
cdecl>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]