在这种情况下 b 是标量对象吗?

Is b a scalar object in this case?

#include <stdio.h>

int main(void) 
{
    char b[5];
    scanf("%4s%4s", b, b);
    printf("%s", b);
}

标量对象的确切定义是什么? 在这种情况下 b 是标量对象吗?

根据 c11 standard、"Arithmetic types and pointer types are collectively called scalar types. Array and structure types are collectively called aggregate types"

所以不,b 不是标量,因为它是一个数组。如果它是数字或指针(如char* b),它将是标量类型。

引自 ISO/IEC 9899:2018 (C18), 6.2.5 (Types)/21:

"Arithmetic types and pointer types are collectively called scalar types. Array and structure types are collectively called aggregate types.47)"

47) "Note that aggregate type does not include union type because an object with union type can only contain one member at a time."


"What is the exact definition of a scalar object?"

标量对象是仅由单个实体组成的对象,例如指针和算术类型的对象。

"Is b a scalar object in this case?"

b 不是 标量 对象,因为标量对象只包含一个实体。 b 等数组是“聚合”。 scanf("%4s%4s", b, b);printf("%s", b); 中指向指针衰减的数组不会改变 b 仍然是数组类型。