![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
To inform the C compiler that construct_trade
is to take a
variable number of arguments, you must supply one or more ordinary
parameters, followed by
ellipses, ...
:
struct trade* construct_trade (int argument_count, ...) {...}
Generally, the value supplied for assignment to the first parameter
indicates how many arguments follow. In a function such as printf
,
the argument-count indication is through the print specifications buried
in a string. In the new version of construct_trade
, the
argument-count indication is much simpler: If only a price is to be
supplied, the argument value provided when construct_trade
is called
is 1
:
construct_trade (1, price)
Alternatively, if both a price and a number of shares are to be supplied,
the value provided is 2
:
construct_trade (2, price, number)