- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
最近的 C 标准为 printf("%s",p)
指定:
If no l length modifier is present, the argument shall be a pointer to the initial element of an array of character type
这是否意味着 p
必须与 char *
兼容,或者应该以更宽松的方式解释这句话?该标准的其他部分是否阐明了此处“字符类型数组”的确切含义?
为什么这很重要:如果该短语被严格解释为意味着 p
必须与 char *
兼容,那么一个重要的结果是无符号字符 *p; ... printf("%s", p);
在 char
已签名且 const char *p; 的编译平台上未定义; … printf("%s", p);
未定义。
最佳答案
The three types
char
,signed char
, andunsigned char
are collectively called the character types. ...
C11 6.2.5 15
所以“字符类型”数组将包含这 3 个。
const
、volatile
和restrict
是各种类型的限定符,属于同一类型类别。它们也适用。
Any type so far mentioned is an unqualified type. Each unqualified type has several qualified versions of its type, corresponding to the combinations of one, two, or all three of the
const
,volatile
, andrestrict
qualifiers. The qualified or unqualified versions of a type are distinct types that belong to the same type category and have the same representation and alignment requirements. A derived type is not qualified by the qualifiers (if any) of the type from which it is derived.
C11 6.2.5 26
关于c - “shall be a pointer to the initial element of an array of character type” 在 C99 7.19/C11 7.21 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18788489/
我是一名优秀的程序员,十分优秀!