-1

How do I define a function in C with a variable number of arguments if I want to calculate a polynom? My function has to have this arguments: the first argument: float x, the second: int n, the rest of the float numbers (coefficents). Thanks a lot!

  • possible duplicate of [C/C++: Passing variable number of arguments around](http://stackoverflow.com/questions/205529/c-c-passing-variable-number-of-arguments-around) – mc110 Jun 18 '14 at 08:20

2 Answers2

0

Write a function with variable arguments. Note that C does not keep track of how many you pass in (unlike many other languages), so you'll have to make "number of coefficients I'm about to give you" an explicit parameter of the function.

Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
0

Best way would be to pass a table, so pointer to float and size of a table. Your argument list then would be float, int, float*, int

Maciej
  • 193
  • 2
  • 11