...
| Code Block |
|---|
|
char const *c = "Hello"; /* Good */
//c[3] = 'a'; would cause a compile error
|
Compliant Solution 1
In cases where the string referenced by c is meant to be modified, use initialization instead of assignment. In this compliant solution, both a and b are modifiable char arrays which have been initialized using the contents of the corresponding string literal.
| Code Block |
|---|
|
char a[] = "abc";
|
The above This code is equivalent to:
| Code Block |
|---|
|
char a[] = {'a', 'b', 'c', '\0'};
|
Non-Compliant Code Example 1
Though it Although this code example is not compliant with the C C99 Standard, this code it executes correctly if the contents of CMUfullname are not modified.
...