这是与QUOT的定义;阵列QUOT;用C? [英] What is the definition of "array" in C?

查看:115
本文介绍了这是与QUOT的定义;阵列QUOT;用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该标准定义的数组类型的一丝不苟,但我没有看到任何定义的阵列

The standard defines array type meticulously, but I don't see any definition for array.

我们可能会说数组类型的对象,然而这不可能是正确的为无类型的对象,被描述为一个数组(如空间由的malloc 分配)。

We might say "object of array type", however that can't be right as untyped objects (e.g. space allocated by malloc) is described as an array.

动机:%S fprintf中规范(C11 7.21.6.1 / 8)说:

Motivation: The specification for %s in fprintf (C11 7.21.6.1/8) says:

参数应该是一个指向字符类型的数组

the argument shall be a pointer to the initial element of an array of character type

但拿code 个char [] =你好;的printf(%S,S + 1); 然后我们通过一个指针到第二个元素。这个定义似乎假设的阵列的手段的任何组连续的对象(S)的

but take the code char s[] = "hello"; printf("%s", s+1); then we passed a pointer to the second element. That definition appears to be assuming that array means any set of contiguous object(s).

编辑:看到我拿起一些不清楚是什么你问票,我的问题是:什么是长期的这一定义的所使用阵列的由ISO / IEC 9899:2011

seeing as I have picked up some "unclear what you're asking" votes, my question is: What is that definition of the term array as used by ISO/IEC 9899:2011 ?

推荐答案

数组中的 C标准,6.2.5,第20段:

Arrays are defined in the C Standard, 6.2.5, paragraph 20:

这是数组类型描述了连续分配非空集
  与特定的成员对象类型的对象,称为元素类型。
  数组类型的特征在于其元件的类型和由数
  阵列中的元素。数组类型被认为是源自其
  元件类型,并且如果它的元素类型是T,阵列类型是
  有时也被称为''T阵'。数组类型的构造
  从元素类型被称为'数组类型派生''。

An array type describes a contiguously allocated nonempty set of objects with a particular member object type, called the element type. Array types are characterized by their element type and by the number of elements in the array. An array type is said to be derived from its element type, and if its element type is T, the array type is sometimes called ‘‘array of T’’. The construction of an array type from an element type is called ‘‘array type derivation’’.

这篇关于这是与QUOT的定义;阵列QUOT;用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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