我有一个函数的 API,该函数获取 ***int
作为参数。
void APIfunc(int ***in_variable)
我编写了一个新函数,我必须使用这个 APIfunc
。
我想在我的函数中使用本地 int
(而不是 int***
),但我想将其传递给 APIfunc
(获取int****
)。
我该怎么做?
最佳答案
调用函数的方式取决于它是分配内存还是仅访问内存。
案例:分配内存
既然它似乎没有关于对象大小、对象类型、对象数量的参数,它是否假设它们?在这种情况下,您需要这样调用它:
int** in_variable;
APIfunc(&in_variable);
案例:它只是访问内存
您必须将数据分配到某处。您需要这样调用它:
int*** in_variable;
// Allocate memory and fill up the data
// ...
// Call the function
APIfunc(in_variable);
希望能为您澄清一些事情。
关于c - 关于指针的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22754351/