【问题标题】:What is ellipsis operator in c [duplicate]什么是c中的省略号运算符[重复]
【发布时间】:2011-04-17 02:31:29
【问题描述】:

可能重复:
What's does … mean in an argument list in C ?

 function fun1(...)
    {
    }

请告诉我在c中的用途和如何使用省略号运算符。 谢谢,

【问题讨论】:

  • 给你一个很好的链接:here

标签: c function ellipsis


【解决方案1】:

省略号用于表示函数的可变数量的参数。例如:

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

然后可以使用不同类型和数量的参数调用上面的 C 函数,例如:

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

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

C99 引入了Variadic macros,它也使用了省略号。

【讨论】:

    猜你喜欢
    • 2011-08-25
    • 2021-04-14
    • 2021-08-30
    • 2011-08-03
    • 1970-01-01
    • 1970-01-01
    • 2014-01-19
    • 1970-01-01
    相关资源
    最近更新 更多