Oracle® Solaris Studio 12.4: C User's Guide

Exit Print View

Updated: March 2015
 
 

6.5.3 const Means readonly

In hindsight, readonly would have been a better choice for a keyword than const. If one reads const in this manner, declarations such as the following example, are easily understood to mean that the second parameter is only used to read character values, while the first parameter overwrites the characters to which it points. :

char *strcpy(char *, const char *);

Furthermore, despite the fact that in the example the type of cpi is a pointer to a const int, you can still change the value of the object to which it points through some other means, unless it actually points to an object declared with const int type.