O'Reilly logo

Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercise 25. Variable Argument Functions

In C, you can create your own versions of functions like printf and scanf by creating a variable argument function, or vararg function. These functions use the header stdarg.h, and with them, you can create nicer interfaces to your library. They are handy for certain types of builder functions, formatting functions, and anything that takes variable arguments.

Understanding vararg functions is not essential to creating C programs. I think I’ve used it maybe 20 times in my code in all of the years I’ve been programming. However, knowing how a vararg function works will help you debug the programs you use and gives you a better understanding of the computer.

ex25.c

  1   2

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required