大约一个函数定义的问题(在参数三个点..) [英] Question about a function definition (three dots in parameters..)
问题描述
我碰到一个函数定义来了:
I came across a function definition:
char* abc(char *f, ...)
{
}
什么是三个点意味着什么?
What do the three dots mean?
推荐答案
的省略号表示存在的参数以下数量可变。你会用他们(也许没有意识到)这个地方是的printf
系列的功能。
The ellipses mean that there are a variable number of arguments following. The place you will have used them (perhaps without realising) are the printf
family of functions.
它们允许你创建的风格,其中的参数是事先不知道的功能,并且可以使用可变参数的函数(的va_start
,的va_arg
和 va_end用来
),以获得在特定的参数。
They allow you to create functions of that style where the parameters are not known beforehand, and you can use the varargs functions (va_start
, va_arg
and va_end
) to get at the specific arguments.
这个链接这里对 printf的一个很好的论文
使用变量参数列表中。
This link here has a good treatise on the printf
use of variable argument lists.
这篇关于大约一个函数定义的问题(在参数三个点..)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!