Variadic Function are those functions which takes variable number of arguments, as many of us are always curious about how printf and scanf works as we can call them with variable number of arguments.

Image for post

How does this work?

You can declare variadic function as same as other function with a last argument function(a,b,c, …), here “…” signals that there can be variable number of arguments to function.It looks like:

int sum(int n, …)

For using this syntax you have to include stdarg.h header File in header section like this.

#include<stdarg.h>

Now we will learn about some macros which we will use in variadic functions.

#variadic-functions #c #c-programming #programming

Variadic functions in C
1.20 GEEK