在这种情况下b是标量对象吗? [英] Is b a scalar object in this case?

查看:152
本文介绍了在这种情况下b是标量对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdio.h>

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

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

What is the exact definition of a scalar object? Is b a scalar object in this case?

推荐答案

引用自ISO / IEC 9899:2018(C18),6.2.5(类型)/ 21:

Quote from ISO/IEC 9899:2018 (C18), 6.2.5 (Types)/21:


算术类型和指针类型统称为标量类型。数组和结构类型统称为聚合类型。47)

47) 请注意,聚合类型不包括联合类型,因为具有联合类型的对象一次只能包含一个成员。








标量对象的确切定义是什么?

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

A scalar object is an object which only consists of a single entity, such as pointers and objects of arithmetic types.


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

"Is b a scalar object in this case?"

b 不是 scalar 对象作为标量对象保留只有一个实体。诸如 b 之类的数组是 聚集。指针数组在 scanf(%4s%4s,b,b); printf(%s,b);中衰减不会改变 b 仍为数组类型。

b isn´t a scalar object as a scalar object hold only one single entity. Arrays such as b are "aggregates". The array to pointer decay in scanf("%4s%4s", b, b); and printf("%s", b); doesn´t change that b is still of array type.

这篇关于在这种情况下b是标量对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆