=>> Tricky questions in C. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

=>> Tricky questions in C.

In C, like any other function, printf() and scanf() is also a function defined in studio.h then how they accept any number of arguments/parameter Example: printf("%d %d %d", a,b,c);

27th Aug 2018, 5:02 AM
Alpha Rays
Alpha Rays - avatar
1 Answer
+ 3
The 'variadic' definition creates functions with a variable number of arguments. The operator is "...", which Javascript ES6 programmers call the 'spread' operator. "How do varargs work in C?" https://jameshfisher.com/2016/11/23/c-varargs.html From the article: void my_printf(char* format, ...); Variables are pushed onto the stack, and it is the caller's responsibility to provide enough / proper values or risk dangerous side-effects.
27th Aug 2018, 5:20 AM
Kirk Schafer
Kirk Schafer - avatar