Firstly, you should be aware that this:
Code:
double convert(double abw_to_abv[9], double abw);
is equivalent to:
Code:
double convert(double abw_to_abv[], double abw);
which is equivalent to:
Code:
double convert(double *abw_to_abv, double abw);
That is, the parameter abw_to_abv is a pointer to double, but we might use the first two versions to indicate that we expect this pointer to double to point to the first element of an array of doubles, or even more specifically to the first element of an array of 9 doubles. But neither of these conditions are enforced by the type system.
Next, you should be aware that this:
Code:
boiler_abv[index] = convert(abw_to_abv[9], boiler_abw);
accesses abw_to_abv out of bounds. abw_to_abv is an array of 9 doubles, so abw_to_abv[9] doesn't exist. What you probably wanted to write is:
Code:
boiler_abv[index] = convert(abw_to_abv, boiler_abw);
the reason is that when passed as an argument, an array is converted to a pointer to its first element, so the array of 9 doubles named abw_to_abv is converted to double*, which is exactly the type of the abw_to_abv parameter of convert. Perfect.
Well, almost. Next, let's take a look at this line in the definition of convert:
Code:
static const size_t length = sizeof(abw_to_abv) / sizeof(abw_to_abv[0]);
Now, if abw_to_abv were an array, this code would work as expected. However, the parameter named abw_to_abv is a pointer to double, so sizeof(abw_to_abv) results in the size of a pointer to double. Clearly, this is independent of how many elements there are in the underlying array.
Therefore, what I would do is to add a parameter to convert:
Code:
double convert(double abw_to_abv[], size_t abw_to_abv_len, double abw);
Now, you can call it like this:
Code:
boiler_abv[index] = convert(abw_to_abv, sizeof(abw_to_abv) / sizeof(abw_to_abv[0]), boiler_abw);
So, you still have the same "divide sizeof the array by sizeof an element" pattern, but this time it is placed where abw_to_abv really is an array, not a pointer used as if it were an array.