2

As we know printf() function, it can hold characters and if needed could have additional arguments. Ex. printf("Programmer"); printf("Programmer %d",14);

How could I add additional arguments in a prototype function? Is it something like some_func(char *str, ...) ?

Aesthetic
  • 763
  • 1
  • 14
  • 31
  • "Is it something like some_func(char *str, ...)?" - Yes. – Maroun Jan 08 '14 at 08:00
  • 1
    part of the standard; you can get some example from [here](http://stackoverflow.com/questions/205529/c-c-passing-variable-number-of-arguments-around) or even from [wp](http://en.wikipedia.org/wiki/Variadic_function#Example_in_C) – ShinTakezou Jan 08 '14 at 08:01

2 Answers2

4

In order to use variable number of arguments in C you need to include the following library

#include <stdarg.h>

printf() in C is an example of function that takes variable number of arguments.

int printf(const char *fmt, ...)

More info here

Fawzan
  • 4,738
  • 8
  • 41
  • 85
1

You have to use the variable argument list provided in C.

Here is a short tutorial on this functionality:

http://www.cprogramming.com/tutorial/lesson17.html

nikpel7
  • 656
  • 4
  • 11