[英]What does ... mean in a c function definition
#include<stdio.h>
void ff(const char *format,...)
{
printf("hr");
}
int main()
{
ff("d","c");
}
I want to know what is the meaning of const char *format,... in my declaration of ff function.我想知道在我的 ff 函数声明中 const char *format,... 的含义是什么。 Moreover, ff function can be called by passing 1 argument, 2 arguments and n arguments.
此外,可以通过传递 1 个参数、2 个参数和 n 个参数来调用 ff 函数。 How this function call is working?
这个函数调用是如何工作的?
const char *format
declares a parameter which is a pointer to a character and can not be changed. const char *format
声明了一个参数,它是一个指向字符的指针,不能更改。 This is a normal way of passing strings in c
.这是在
c
中传递字符串的正常方式。
The ...
is a declaration of variable arguments, it basically says there will be more arguments to this function, we don't know how many or of what type they will be. ...
是变量参数的声明,它基本上是说这个函数会有更多的参数,我们不知道它们有多少或什么类型。 See http://www.tutorialspoint.com/cprogramming/c_variable_arguments.htm for an introduction to variable arguments.有关可变参数的介绍,请参阅http://www.tutorialspoint.com/cprogramming/c_variable_arguments.htm 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.