const char*

Doug Gwyn gwyn at smoke.brl.mil
Mon May 13 17:32:09 AEST 1991


In article <1742 at targon.UUCP> andre at targon.UUCP (Andre van Dalen) writes:
>Does this mean that you can transform a const char * by calling a function?
[...]
>This would break the clean behaviour that can be forced through
>the use of const pointers. Am I right here or did I miss something?

You missed a lot!  You don't need to call a function in order to
convert type "const char*" to type "char *"; a cast will suffice.
The "const" in the strchr() parameter type does not mean what you
think it does, either.  Finally, no "illegal" action occurs just
by conversion of the pointer types, but rather only when the
pointer to non-const is used in an attempt to modify what it
points to, if what is pointed to is really a const-qualified object.



More information about the Comp.std.c mailing list