8.6. Using const with Pointers
const enables you to inform the compiler that the value of a particular variable should not be modified. Many possibilities exist for using (or not using)
const with function parameters, so how do you choose the most appropriate? Let the principle of least privilege be your guide. Always give a function enough access to the data in its parameters to accomplish its specified task, but no more. This section discusses how to combine
const with pointer declarations to enforce the principle of least privilege.
Chapter 6 explained that when an argument is passed by value, a copy of the argument is passed to the function. If the copy is modified in the called function, the original value in the caller does ...