...
This noncompliant code example concatenates wide and narrow string literals. Although the behavior is undefined in this case, the programmer probably intended to create a wide string literal.
Code Block | ||||
---|---|---|---|---|
| ||||
wchar_t *msg = L"This message is very long, so I want to divide it " "into two parts."; |
...
If the concatenated string needs to be a wide string literal, each element in the concatenation must be a wide string literal, as in this compliant solution.
Code Block | ||||
---|---|---|---|---|
| ||||
wchar_t *msg = L"This message is very long, so I want to divide it " L"into two parts."; |
...
If wide string literals are unnecessary, it is better to use narrow string literals, as in this compliant solution.
Code Block | ||||
---|---|---|---|---|
| ||||
char *msg = "This message is very long, so I want to divide it " "into two parts."; |
...