Use of Const keyword in ANSI C
Henry Spencer
henry at utzoo.uucp
Sat Sep 10 02:06:16 AEST 1988
In article <441 at optilink.UUCP> cramer at optilink.UUCP (Clayton Cramer) writes:
> const char* C;
> Test1.C = "not a test case"; /* compiler accepts this -- bad */
>
>Should the attempt to set Test1.C to point to another string cause a
>complaint from the compiler?
No. You have misunderstood the (messy) syntax of const. "const char *"
is a pointer to const char, not a const pointer to char. To get a const
pointer to char, say "char *const C;" instead. Yes, this is ugly.
--
Intel CPUs are not defective, | Henry Spencer at U of Toronto Zoology
they just act that way. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list