![]() |
![]() |
![]() |
![]() |
![]() |
|
To define the mean_price function, note that you hand it an array of
pointers to trade objects. The appropriate data type for the
corresponding parameter cannot be, say, struct trade *array, for
that would specify an array of trade objects, rather than pointers
to trade objects. Accordingly, the correct specification must
include two asterisks:
struct trade **array. Also, as there is no end-of-array marker for
arrays other than character arrays, you also must hand mean_price the
length of the array:
double mean_price (struct trade **array, int length) {
int counter; double sum = 0.0;
for (counter = 0; counter < length; ++counter)
sum = sum + array[counter] -> price;
return sum / counter;
}