|
|
|
|
|
by etanol
5053 days ago
|
|
The document talks about C89, even though the last Copyright year is 2003. Isn't it about time that we start movin on? Where are the restricted pointers, the flexible array member and so on? And, by the way, I think the comment at the bottom of page 27 is not correct: The qualifier const can be added to the left of a variable or parameter type to declare that the code using the variable will not change the variable. As a practical matter, use of const is very sporadic in the C programming community. It does have one very handy use, which is to clarify the role of a parameter in a function prototype... Actually, the use of const is encouraged as it helps the compiler to catch more errors as well as to enable some optimizations. |
|
The qualifier const can be added to the left of a variable or parameter type
If you have the declaration
Adding const to the left of the type doesn't make the variable immutable: This indicates that str will point to a character or string which must not be mutated. str itself can be reassigned. To make str immutable, you need or Const does tend to be used little in pure C, though you pretty much can't escape it in C++ code. (I also use it a lot in C, and have type warnings/errors cranked up to max)