📑 Table of Contents

VLA可以指:

組織

编辑

科技

编辑

其他

编辑

📚 Artikel Terkait di Wikipedia

可变长数组

可变长数组(英語:Variable-length array)是指在计算机程序设计中,数组对象的长度在运行时(而不是编译时)确定。 支持可变长数组的程序设计语言有:Ada, ALGOL 68 (for non-flexible rows), APL, C99 (以及C11 ) ,C# , COBOL

Sizeof

#include <stddef.h> size_t flexsize(int n) { char b[n + 3]; /* Variable length array */ return sizeof b; /* Execution time sizeof */ } int main(void)

数组

int a; double b; char c[]; }; Visual C++ 2015支持上述语法。 C99引入了可变长数组(variable length array,简称VLA),只能定义在块作用域或函数原型作用域,必须无链接性。其数组长度在编译期可变,但在运行期该数组对象一旦生成就不可改变数组长度了。例如:

语言集成查询

ToArray(); 对比流利语法和C#的传统语法: // extension methods make LINQ elegant IEnumerable<string> query = names .Where(n => n.Contains("a")) .OrderBy(n => n.Length)

ALGOL 60

An array is a set of elements, called the components of the array, everyone of which behaves like a simple variable. The components of an array are distinguished

类型双关

managed { .locals init ( [0] uint8[] ) .maxstack 3 // create a new byte array with length sizeof(T) and store it in local 0 sizeof !!T newarr uint8 dup // keep

JavaScript语法

same as myArray[1] 声明一个数组可用Array字面量或者Array构造函数: let myArray; // Array literals myArray = [1, 2]; // length of 2 myArray = [1, 2,]; // same array - You can

Ruby

使用块迭代数组: array = [1, 'hi', 3.14] array.each { |item| puts item } # => 1 # => 'hi' # => 3.14 array.each_index { |index| puts "#{index}: #{array[index]}"