开发者

What is ellipsis operator in c [duplicate]

开发者 https://www.devze.com 2023-01-18 01:21 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: What's does … mean in an argument list in C ?
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

What's does … mean in an argument list in C ?

 function fun1(...)
    {
    }

Please tell me about what is the use and how to use 开发者_开发百科ellipsis operator in c. Thanks,


An ellipsis is used to represent a variable number of parameters to a function. For example:

void format(const char* fmt, ...)

The above function in C could then be called with different types and numbers of parameters such as:

format("%d-%d-%d", 2010, 9, 25);

and

format("product: %s, price: %f", "HDD", 450.90);

C99 introduced Variadic macros which also makes use of ellipsis.

0

精彩评论

暂无评论...
验证码 换一张
取 消