From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.



变长数组与LabWindows/CVI



主要软件:
主要软件版本: 7.1
主要软件修正版本: N/A
次要软件: LabWindows/CVI Development Systems>>LabWindows/CVI Base Package

问题: LabWindows/CVI是否支持变长数组?

解答:

有两种声明数组的方式:

  • 静态数组:
          int myArray [25];

          数组长度在声明数组时指定。

  • 动态数组:
          int * myArray;
          myArray = malloc (25 * sizeof(int));

          这些数组的长度被定义为动态分配给它的内存大小(mallocrealloc)。

    这两种方法都被LabWindows/CVI支持。另一种方式,是将变长数组的长度通过存放在一个特定变量中的数值来定义。

  • Variable Length Arrays:
          int arrayLength = 25;
          int myArray [arrayLength];

    ANSI 89不支持变长数组。由于LabWindows/CVI严格遵循ANSI 89标准,因此您不能在CVI中定义变长数组。


  • 相关链接:

    附件:





    报告日期: 10/31/2005
    最近更新: 03/14/2010
    文档编号: 3QUDF8K7