Use of Variable Argument Lists

Study the applications of variable argument lists.

We'll cover the following

You can pass a variable number of arguments to functions, like printf( ) and scanf( ). We can also write functions that receive different numbers of arguments in different calls.

Example program

Here, we propose to write a function call, findmax( ), that finds the maximum out of the numbers passed to it. To do this, we need to use three macros: va_start, va_arg, and va_list. These macros are declared in the file: stdarg.h.

See the code given below!

Get hands-on with 1200+ tech skills courses.