An Entity of Type: work, from Named Graph: http://dbpedia.org, within Data Space: dbpedia.org

C struct data types may end with a flexible array member with no specified size: struct vectord { short len; // there must be at least one other data member double arr[]; // the flexible array member must be last // The compiler may reserve extra padding space here, like it can between struct members}; Typically, such structures serve as the header in a larger, variable memory allocation: struct vectord *vector = malloc(...);vector->len = ...;for (int i = 0; i < vector->len; i++) vector->arr[i] = ...; // transparently uses the right type (double)

Property Value
dbo:abstract
  • C struct data types may end with a flexible array member with no specified size: struct vectord { short len; // there must be at least one other data member double arr[]; // the flexible array member must be last // The compiler may reserve extra padding space here, like it can between struct members}; Typically, such structures serve as the header in a larger, variable memory allocation: struct vectord *vector = malloc(...);vector->len = ...;for (int i = 0; i < vector->len; i++) vector->arr[i] = ...; // transparently uses the right type (double) (en)
  • 灵活数组类型是C99引入的语言特性。即在struct数据类型的最后一个数据成员,可以为一个未指明长度的数组类型。例如: struct double_vector_st { size_t length; double array[]; // the flexible array member should be last}; sizeof运算符作用于这个struct,返回灵活数组成员的偏移量。在堆上分配这种struct,应该保留灵活数组的空间。如下例: struct double_vector_st *allocate_double_vector(size_t len) { struct double_vector_st *vec = malloc(sizeof *vec + len * sizeof vec->array[0]); if (!vec) { perror("malloc double_vector_st failed"); exit(EXIT_FAILURE); } vec->length = len; for (size_t ix = 0; ix < len; ix++) vec->array[ix] = 0.0; return vec;} C++语言标准尚未支持灵活数组类型。但Visual C++2015支持。 (zh)
dbo:wikiPageID
  • 44866380 (xsd:integer)
dbo:wikiPageLength
  • 3541 (xsd:nonNegativeInteger)
dbo:wikiPageRevisionID
  • 1075730748 (xsd:integer)
dbo:wikiPageWikiLink
dbp:wikiPageUsesTemplate
dcterms:subject
gold:hypernym
rdf:type
rdfs:comment
  • C struct data types may end with a flexible array member with no specified size: struct vectord { short len; // there must be at least one other data member double arr[]; // the flexible array member must be last // The compiler may reserve extra padding space here, like it can between struct members}; Typically, such structures serve as the header in a larger, variable memory allocation: struct vectord *vector = malloc(...);vector->len = ...;for (int i = 0; i < vector->len; i++) vector->arr[i] = ...; // transparently uses the right type (double) (en)
  • 灵活数组类型是C99引入的语言特性。即在struct数据类型的最后一个数据成员,可以为一个未指明长度的数组类型。例如: struct double_vector_st { size_t length; double array[]; // the flexible array member should be last}; sizeof运算符作用于这个struct,返回灵活数组成员的偏移量。在堆上分配这种struct,应该保留灵活数组的空间。如下例: struct double_vector_st *allocate_double_vector(size_t len) { struct double_vector_st *vec = malloc(sizeof *vec + len * sizeof vec->array[0]); if (!vec) { perror("malloc double_vector_st failed"); exit(EXIT_FAILURE); } vec->length = len; for (size_t ix = 0; ix < len; ix++) vec->array[ix] = 0.0; return vec;} (zh)
rdfs:label
  • Flexible array member (en)
  • 灵活数组类型 (zh)
owl:sameAs
prov:wasDerivedFrom
foaf:isPrimaryTopicOf
is dbo:wikiPageWikiLink of
is foaf:primaryTopic of
Powered by OpenLink Virtuoso    This material is Open Knowledge     W3C Semantic Web Technology     This material is Open Knowledge    Valid XHTML + RDFa
This content was extracted from Wikipedia and is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy