-4
#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. Moreover, ff function can be called by passing 1 argument, 2 arguments and n arguments. How this function call is working?

David Waters
  • 11,979
  • 7
  • 41
  • 76

1 Answers1

4

const char *format declares a parameter which is a pointer to a character and can not be changed. This is a normal way of passing strings in 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.

David Waters
  • 11,979
  • 7
  • 41
  • 76