The C standard allows an array to be initialized using a string literal that fits exactly in the array, not counting the terminating null character. However, this has limited utility and the potential to cause vulnerabilities when a null-terminated byte string is assumed. Consequently, this practice is disallowed by this standard. A better approach is to not specify the dimension of a character array initialized with a string literal, as the compiler will automatically allocate sufficient space for the entire string literal, including the terminating null character.
Initializing an array using a string literal to fit exactly without a null byte is not allowed in C++.
Non-Compliant Code Example
...