CERT-STR30-C
In this section:
Synopsis
Do not attempt to modify string literals.
Enabled by default
Yes
Severity/Certainty
Low/High

Full description
String literals are arrays of static storage duration. It is unspecified whether these arrays are distinct from each other. The behavior is undefined if a program attempts to modify any portion of a string literal.
Coding standards
- CERT STR30-C
Do not attempt to modify string literals
Code examples
The following code example fails the check and will give a warning:
void example(void) {
char *str = "const";
str[0] = 'C';
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
char str[] = "string";
str[0] = 'S';
}