The omission of const correctness in code is a big pet peeve of mine.
Quick, what’s the difference between:
1
2
3
4
5
|
const char * CONSTANT_STRING_TABLE[] = {
"A",
"B",
"C"
};
|
and:
1
2
3
4
5
|
const char * const CONSTANT_STRING_TABLE[] = {
"A",
"B",
"C"
};
|
?
Unfortunately, the former lets you modify the strings in the CONST_STRING_TABLE:
1 |
CONST_STRING_TABLE[0] = "B";
|
while the latter doesn’t (which is probably what you wanted), generating a compiler error instead. But I know I’ve seen the former plenty of times when reading through peoples’ code. That, along with the following, drive me up the wall whenever I run into them.
1 |
const char * CONSTANT_STRING = "Some \"constant\" string.";
|