C – Variable length argument

Prev     Next

  • Variable length arguments is an advanced concept in C language offered by c99 standard. In c89 standard, fixed arguments only can be passed to the functions.
  • When a function gets number of arguments that changes at run time, we can go for variable length arguments.
  • It is denoted as … (3 dots)
  • stdarg.h header file should be included to make use of variable length argument functions.

Example program for variable length arguments in C:

Output:

The value from first function call = 5
The value from second function call= 14

In the above program, function “add” is called twice. But, number of arguments passed to the function gets varies for each. So, 3 dots (…) are mentioned for function ‘add” that indicates that this function will get any number of arguments at run time.

Prev     Next

Share this website !!!
Facebook Twitter Linkedin

1. Online Compilers - Compile & Run your C/C++ programs:

✅ Online Compilers

2. Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!