c++ - 如何在 C++ 中将数组声明为参数?

标签 c++ arrays

我在我的 iOS 项目中使用专有代码,我只能访问我的项目的头文件。如何在 C++ 中声明一个数组,以便在我调用时返回一个数组?

这里是头文件方法,

 short WI_GetIDsFromList(int32_t module, int32_t *idsArray, uint32_t *count);

如何声明一个数组来接收一个 in32_t 数组?进行此调用时,我不断收到 returnedIdsArray 的参数错误?它非常适合计数吗?我试着把它变成一个指针,但它没有用?

    //Array of ID's
    int32_t returnedIdsArray[] = {};

    // Array of ID's count
    uint32_t count;

 rc += WI_GetIDsFromList(mod, returnedIdsArray, &count);

另一个例子

short dpCount;

//Get number of data points from the device
WI_GetDatapointCount(modIDHDS, &dpCount);

//dpCount now has returned value of method WI_GetDatapointCount
NSLog@"%d", int(dpCount);

最佳答案

我认为 Mochi 的问题是如何声明适合标题中给定函数需要的数组。如果我没理解错的话,他对以数组为参数的函数没有影响。

你试过吗:

int32_t returnedIdsArray[MaximumExpectedIds];

也许 API 中还有一个函数可以为您提供可用于确定数组大小的 ID 数量。

关于c++ - 如何在 C++ 中将数组声明为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47684987/

相关文章:

c++ - 具有历史的搜索结构(持久性)

c++ - 标准允许#pragma 做什么?

c# - 从随机数组中提取最小值和最大值以显示

c++ - 固定大小数组的非成员 std::empty 重载的返回值

javascript - 将动态值插入对象数组,javascript

c++ - 从 C 调用共享 .so 中的函数

C++ undefined reference

c++ - QT creator gcc cout 在终端

javascript - 使用 ajax 发送一个值更改数组并进行比较

javascript - 如何在javascript中定义多个数组