What enables C to support variable number of function arguments (varargs), while other languages (like Java) do not support this feature? What is special in C which is not there in Java to support this?

Recommended Answers

All 2 Replies

Java has variable-length argument lists.

>What enables C to support variable number of function arguments (varargs)
Usually arguments are placed on a stack, and by knowing how that stack is organized, the compiler writer can write macros to iterate over the arguments. It's actually pretty simple, but very non-portable.

>What is special in C which is not there in Java to support this?
Assuming Java didn't support variable arguments (which it does), the difference is that the language is defined to support it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.