以下是否定义明确?
const char not_a_c_string[] = { 'h', 'e', 'l', 'l', 'o' }; printf( "%.5s", (const char*) not_a_c_string );
这是关于具体形式的问题"%.5s",而不是如何打印可能不是NUL终止的字符串?因为这个问题已在这里得到解答,其中"%.*s"提出了构造.
"%.5s"
"%.*s"
c printf undefined-behavior language-lawyer
c ×1
language-lawyer ×1
printf ×1
undefined-behavior ×1