Const-correctness in C

Viewed 1563

Apparently it's good practice to use const unless something is meant to be mutable, but how far do you go? If I have an array of strings, should my function signature include this?

char const * const * const my_strings

I'm not going to be modifying it whatsoever, so it's a constant pointer to the first element of an array of constant pointers to the first elements of arrays of constant characters. That's a mouthful, and the code is nearly unreadable. All this is a simple data structure like argv.

I feel as though const should be default and there should be a mutable keyword.

Do you generally just one of those consts? What's the point of that then, if you can still easily change it by dereferencing more or less?

1 Answers
Related