大约一个函数定义的问题(在参数三个点..) [英] Question about a function definition (three dots in parameters..)

查看:120
本文介绍了大约一个函数定义的问题(在参数三个点..)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到一个函数定义来了:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆