I need to evaluate function with list of arguments from array of arguments as in this example:
int compute(...) {
int n;
va_list params;
va_start(params, n);
// some custom computation with no "va" output
va_end(params);
}
And some array of int (which is dynamic array, don't rely on fixed size):
int arr[10] = {0, 1, 3, 7, 8, 1, 3, 5, 7, 9};
And I need to call compute like JS function compute.apply(this, arr)
I'm implementing some library with C that's why I need it.
In C++ this is std::apply but I want the same in C.
Thanks
nelements, write a function that takes that array and its length as parameters:int compute(const int *arr, size_t n).std::applyfrom C++ in Ccomputefunction with the given array?qsortlike this. If your arrays can be heterogenous, you can create a variant type as a tagged union like this. Note how both approaches still must manage their memory explicitly. Is that what you are looking for?