Ellipsis (computer programming): Difference between revisions

Content deleted Content added
Line 34:
In the [[C (programming language)|C programming language]], an ellipsis is used to represent a [[variadic function|variable number of parameters]] to a [[function (programming)|function]]. For example:
 
:<code>voidint funcprintf( const char* strformat, ... );</code><ref>http://www.cplusplus.com/reference/cstdio/printf/</ref>
 
The above function in C could then be called with different types and numbers of parameters such as:
 
:<code>func("inputnumbers string%i %i %i", 5, 10, 15);</code>
and
:<code>func("input string %s, %f", "another string", 0.5);</code>
 
[[C99]] introduced macros with a [[variadic macro|variable number of arguments]].<ref>Working draft changes for C99 preprocessor synchronization - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm</ref>
As of version 1.5, [[Java (programming language)|Java]] has adopted this "varargs" functionality. For example:
:<code>public int func(int num, String... strings)</code>
 
[[C99C++11]] included the C99 preprocessor, and also introduced macrostemplates with a [[variadic macrotemplate|variable number of arguments]].
 
===Java===
[[C++0x]] introduces templates with a [[variadic template|variable number of arguments]].
 
As of version 1.5, [[Java (programming language)|Java]] has adopted this "varargs" functionality. For example:
:<code>public int func(int num, String... strings)</code>
 
===PHP===