我读过一本书,叫《Pointers On C》。在那本书中,有一种类型称为标量类型。
我知道算术类型和指针类型统称为标量类型,但我想知道标量类型和聚合类型有什么区别以及什么场合使用它们?
C11-§6.2.5 类型 (p21):
Arithmetic types and pointer types are collectively called scalar types. Array and structure types are collectively called aggregate types.46)
标量数据类型只能保存单个数据项,而聚合类型可以保存多个数据项。
int a; //Scalar Type
char c; //Scalar Type
float *p; //Scalar Type
char str[10]; //Aggregate Type
struct s{
int a;
float b[5];
} ss; //Aggregate Type
46) Note that aggregate type does not include union type because an object with union type can only contain one member at a time.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)